Giter Site home page Giter Site logo

Comments (2)

GeraldLx avatar GeraldLx commented on June 1, 2024

Version 2 works for me without RedundantArgumentMatcherException and is the right syntax.

Personally I would ask if it is really a good thing to use a mocking framework for this test?
Why not just write the test without it?

E.g.:

  [TestMethod]
  public void TestIt()
  {
    var it = new DoIt();

    int? value1 = null;
    int? value2 = null;


    var actual = it.Execute((x, y) =>
    {
      value1 = x;
      value2 = y;

      return true;
    });

    actual.Should().BeTrue();
    value1.Should().Be(1);
    value2.Should().Be(2);
  }

Not as fancy as the NSubstitute version but way easier to understand.

from nsubstitute.

hicks86 avatar hicks86 commented on June 1, 2024

Thank you, so the 2nd way is probably what I need to go for, maybe I need an update.

But yeah you make a good point, I can do all that funky mocking manually and at least I have control and know what it is doing.
Damn I fell back into the "mock all the things" trap.

Cheers

from nsubstitute.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.