how to verify that a method was called with an argument of a specific type

Viewed 6737

I need to verify that a method was called with an object of a specific type

this is the interface with the method that I want to test that it was called:

interface IPlayer
{
   void Send(object message);
}

the test:

var player1 = A.Fake<IPlayer>();
room.AddPlayer(player1);

room.DoSomething();

A.CallTo(() => player1.Send(A<Type1>.Ignored)).MustHaveHappened();

since there are multiple calls to player1.Send with many different objects I get InvalidCastException

anybody knows how to do this properly ?

1 Answers
Related