Reputation: 51
I getting the following error when try check type of mock Object:
Assert.IsType() Failure
Expected: ProjetoAxion.Domain.Entities.User
Actual: Castle.Proxies.UserProxy
Example:
var userMock = Mock<User>().Object;
Assert.IsType<User>(userMock);
How can I Assert it type with Moq is type mocked?
Upvotes: 2
Views: 2670
Reputation: 9519
This is the way how moq
internally works. It uses DynamicProxy
under the hood to create an interceptable proxy where the proxy Castle.Proxies.UserProxy
extends User
. Otherwise, how would moq
be able to intercept invocations... Knowing that fact you could use IsAssignableFrom<User>
instead of IsType<User>
.
Assert.IsAssignableFrom<User>(userMock);
Upvotes: 2