开发者

Moq mocking a class

开发者 https://www.devze.com 2023-03-23 20:56 出处:网络
I\'m new to Moq and mocking. I have a class Car and I want to Mock this class: Car car = Mock<Car>();

I'm new to Moq and mocking.

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

Car car = Mock<Car>();
开发者_如何学Python

I'm getting the error "Cannot implicitly convert type 'Moc.Mock' to 'Car'.

It seems I could do this if I had:

Car car = Mock<ICar>();

However I don't actually have a ICar

Can anyone tell me how to achieve the mock of Car?


var mockCar = Mock<Car>();
// Configure the mock properties and methods.

Car car = mockCar.Object;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号