chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Is it possible using Isolator to set expectations for the code as you go and verify at the end? In the previous API, I think you could do the following .ExpectAndReturn() to set expectations and then at the end do MockManager.Verify() to check those expectations. I need expectations to be set based on conditionals and then ultimately verify any expectations that were set. Any suggestions?
asked by James (640 points)

3 Answers

0 votes
Hi James,
Sure you can do that, just use Isolate.Verify API.

Here is an example:
[Test]
public void Test()
{
    var fake = Isolate.Fake.Instance<ClassToFake>();
    fake.Foo(1);
    Isolate.Verify.WasCalledWithAnyArguments(() => fake.Foo(1));
    // Use WasCalledWithExactArguments when you want to verify the call and the arguments ...
    //Isolate.Verify.WasCalledWithExactArguments(() => fake.Foo(1));
}


:arrow: Note that unlike the previous API you need specify explicitly what method call you want to verify.

Hope it helps, Please let me know if you have more questions.
answered by ohad (35.4k points)
0 votes
I need to be more specific; I want to be able to define my expectations before I call the method I am testing. In my case, I have a tool that reads a .csv file and generates code for a method based. I would like my test to be able to read through the input file and create a set of expectations, then call the method that was generated (the method I want to test) and finally verify that those expectations were met. Since the expectations are dependent on the contents of the input file (which can change) I don't see a way to use the method you suggested to verify the correct code was generated for the method I want to test. Is what I'm suggesting possible?
answered by James (640 points)
0 votes
Hi James,

Can you send me code example of what you are trying to do?
I'll send you mail from our support please reply to it.
answered by ohad (35.4k points)
...