I am having some problems, which are doing some unit-testing.
If I have a function like this:
public string GetName (IMapinfoWrapper wrapper) {return wrapper.Evaluate ("my com command"); /// "My Com Command" is the same all the time. }
Then I have a test that checks the return value of the GetName function:
[Test] Public Zero Test () {Mock End Lieutenant; IMapinfoWrapper & gt; Fake = new fake & lt; IMapinfoWrapper & gt; (); fake. (MapInfo = & gt; mapinfo.Evaluate (this is any; string & gt; ())). Returns ("table name"); Assign. Erequal ("table name", gatename (mock object)); }
So my question is that the fake should be defined like this:
mock.Expect (mapinfo => mapinfo.Evaluate (this Any & lt; string & gt; ()) .Returns ("TableName");
or like it:
mock.Expect (mapinfo = & gt; mapinfo.Evaluate ("My Com Command"). Returns ("The table name ");
My only problem in using the other way is that I feel that I have to use the" my com command "string internally to implement the method I want to constitute.
Is this what I should do or am doing all this wrong?
I only started testing the unit And have fun, so I still can not believe how everything should go together.
If it is expected that any string evaluation will return "TableName", then call the call on IsAny.
Otherwise, if you are expecting a specific output of specific input, like "my com command" is a case of passing, then Pass the question.
It seems that you are not looking for specific input, but rather (in this case) are investigating basic discretion, so I say ULD is that the former is the right move (again In this case, but you should have more specific cases if you have access to it).
Comments
Post a Comment