c# - Should I be using a moq just to test if a method is called? -


I have some test codes that look like this:

  [test] public Zero RunTableInfoCommandShouldCallTableINFOWithName () {String expectcommand = "TableInfo (TestTable, 1)"; Table. The Rantal Info Commands (Mockmapinfo.Object, "TestTable", TableInfoInM.TABININFFofFANUI); // it's just an em for 1. Mockmapinfo Verify (M => M. Evilt (Expected Command)); }  

Would I like to make a test with a counterfeit object, to see that the requisite command used by the counterfeit is called "RunTableInfoCommand"

< P> Or should I just have a test that checks the output of the Runtime Infocom and uses fake there because it tests to see that the call is also done.

Runtime Infocom gives a string, as you can see that I have not used it here because I just want to see if the tablefo command is also called.

I do not think you should test to see if the function you are calling Is called. You should believe that it will happen.

You can do the best test of behavior. For example, a test that is a task in which Runtime Infocom is called as part of its expected behavior.

Then check what you want.

For example

  [Test] Public Zero GetTableName () {string expectedName = "TableInfo (TestTable, 1)"; Confirm. First (testTable.GetTableName (mockmapinfo.Object) = ExpectedName); }  

In this example, GetTableInfoCommand call GetTableName which will actually function calls. So you are testing the interface or behavior of an object.

Hope it helps.


Comments