Mock taunts class

I am new to Moq and mock.

I have a Car class, and I want to Mock this class:

 Car car = Mock<Car>(); 

I get the error message "It is not possible to implicitly convert the type" Moc.Mock "to" Car ".

It seems I could do this if I had:

 Car car = Mock<ICar>(); 

However, in fact I do not have ICar

Can someone tell me how to achieve a Car layout?

+6
source share
1 answer
 var mockCar = Mock<Car>(); // Configure the mock properties and methods. Car car = mockCar.Object; 
+13
source

Source: https://habr.com/ru/post/893820/


All Articles