Based on the use of Moq, I'm used to being able to set Mocks as Confirmed. As you know, this is convenient if you want your test code to be actually called the dependency method.
eg. in Moq:
mockDependency.Setup(x => x.SomethingImportantToKnow()).Verifiable("Darn, this did not get called.");
target = new ClassUnderTest(mockDependency);
target.DoThingsThatShouldUseTheDependency();
mockDependency.Verify();
I use the VS2012 "Fakes Framework" (due to the lack of a better name for it), which is pretty smooth, and I'm starting to prefer Moq because it seems a little more expressive and makes Shims easy. However, I cannot figure out how to reproduce behavior similar to the Moq Verifiable / Verify implementation. I found the InstanceObserver property in Stubs, which is similar to what I want, but there is no documentation as of 9/4/12, and I don’t understand how to use it, even if it is correct.
- - Moq Verifiable/Verify VS2012?
- 9/5/12 -
, , VS2012 Fakes. , - , . , (, ).
[TestClass]
public class ClassUnderTestTests
{
private class Arrangements
{
public ClassUnderTest Target;
public bool SomethingImportantToKnowWasCalled = false;
public Arrangements()
{
var mockDependency = new Fakes.StubIDependency
{
SomethingImportantToKnow = () => { SomethingImportantToKnowWasCalled = true; }
}
Target = new ClassUnderTest(mockDependency);
}
}
[TestMethod]
public void DoThingThatShouldUseTheDependency_Condition_Result()
{
var arrangements = new Arrangements();
arrangements.Target.DoThingThatShouldUseTheDependency();
Assert.IsTrue(arrangements.SomethingImportantToKnowWasCalled);
}
}
- 9/5/12 End edit -
!