Friday, 15 April 2011

c# - FakeItEasy: Reset Fake Calls History / Ignore Call -


I want to reset the simulated call history or ignore the call.

The fake implied method is called in the Init method in the class constructor and I want to ignore this call because it is not part of the trial process.

Here's an example:

  [TestClass] Public class UnitTest1 {Private MyFakedClass myFakedObject; Private swine suit; [Test Initialize] Public Zero Init () {myFakedObject = A. Fake & lt; MyFakedClass & gt; (); Sut = new SUT (myFakedObject); // myFakedObject.AssertedMethod ()} [TestMethod] to the Constructor Public Zero testMethod1 () {sut.TestedMethod (); // TestedMethod myFakedObject.AssertedMethod () calls again ... a. Colo (() => myFakedObject.AssertedMethod ()). Repeat (Really. Once); // ..... then this is false}}  

I am the prostitute Love me I think the call from within the manufacturer is important.

However, if you really need to do this:

When FakeItEasy version ≥ 3.2.0 , you ClearRecordedCalls You can use:

  fake. Cleaner card call (fake);  

When the 2.0.0 ≤ FakeItEasy version & lt; 3.2.0 , consider the ForceWire subtraction method ().

When Fake Italia Edition & lt; 2.0.0 , you can use scope:

  [test] Public Zero TestMethod1 () {(Fake Cretescope) {sut.TestedMethod (); // call myFakedObject.AssertedMethod () again A.CallTo ((=) myFakedObject.AssertedMethod ()) .hostened (duplicated.in fact once); }}  

The scope of the scope to look at the calls made through the scope of the scope is using is dead .

You can also create a radius in it to set it in the TestInitialize and TestCleanup method, if you enter outside of all your test methods Want to use.


No comments:

Post a Comment