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

I have a private method called "method1" as follows:
public class Myclass : IMyclass{
private void method1(IList<class1> class1List)

I want to verify this method was called in my test method in the test project. following is my test method:

public void TestMethod1()
Myclass myClass1= new Myclass(x, y);
IList<class1> class1List= new List<class1>(); //Assume this list has values
Isolate.Verify.NonPublic.WasCalled(myClass1, "method1").WithArguments(class1List);


but Once I run the test method i got the following error:
TypeMock Verification: Method A.B.C.....Myclass.method1() was expected but was not called

But this "method1()" was called in the "myClass1.Method2(para1)" when i was debugging.

Can somebody tell me where I'm wrong?


asked by niluka (3.1k points)

1 Answer

0 votes
Hi Niluka,

You can not use Verify on live objects.

You could do something like the following:
Myclass myClass1= Isolate.Fake.Instance<Myclass>(Members.CallOriginal, ConstructorWillBe.Called, x, y);

answered by yoel (1.9k points)