I'm using the beta of Microsoft Fakes in Visual Studio 11. How can I verify that a dependency's method was called by my system under test?
相关问题
- Dependencies while implementing Mocking in Junit4
- How to unit test a reactive component where ngCont
- Access for global variables JavaScript unit testin
- Googletest Parametrized tests crash
- Is there any means by which I could evaluate the t
相关文章
- How to replace file-access references for a module
- How to mock methods return object with deleted cop
- What is a good way of cleaning up after a unit tes
-
EF6 DbSet
returns null in Moq - React testing library: Test attribute / prop
- React/JestJS/Enzyme: How to test for ref function?
- python unit testing methods inside of classes
- Running into System.MissingMethodException: Method
As verify functionality is not included in the Microsoft Fakes Beta, the code below is a basic test for whether or not a method on a dependency was called. You could enhance the
true
test to test parameter values or other conditions of a proper call.Test:
Classes:
Uncomment the line above to see the test pass.
Have a look to this post: http://www.peterprovost.org/blog/2012/11/29/visual-studio-2012-fakes-part-3/
Cheers
Another option that you have for doing behavioral verification with the Microsoft Fakes framework is to use the StubObserver class thats included in the Microsoft.QualityTools.Testing.Fakes.Stubs namespace. Using the framework, you generate a stub for your dependency. Then on your Stub you can set the InstanceObserver property to a new StubObserver. Using the StubObserver class, you can "query" the method calls made to your dependency. Your test method would look something like below