本文整理汇总了C#中CarController.Index方法的典型用法代码示例。如果您正苦于以下问题:C# CarController.Index方法的具体用法?C# CarController.Index怎么用?C# CarController.Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CarController
的用法示例。
在下文中一共展示了CarController.Index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index_GetCar
public void Index_GetCar()
{
var expectedResult = new[]
{
new CarModel
{
CarId = 1,
Name = "Foo",
Color = "FooColor",
Price = 11111,
InventoryCount = 1,
Manufacturer = new ManufacturerModel
{
ManufacturerId = 1,
Country = "FooCountry",
Name = "FooManu"
}
}
};
var mockService = new Mock<ICarService>(MockBehavior.Strict);
mockService.Setup(s => s.GetCar(expectedResult[0].CarId)).Returns(expectedResult[0]);
var mockMapper = new Mock<Mappers.IMapper>(MockBehavior.Strict);
mockMapper.Setup(m => m.Map(expectedResult, typeof(IEnumerable<CarModel>), typeof(IEnumerable<CarViewModel>)));
var controller = new CarController(mockService.Object, mockMapper.Object);
var result = controller.Index(false, expectedResult[0].CarId) as ViewResult;
var model = result.Model as CarModel[];
Assert.IsNotNull(model);
mockService.Verify(foo => foo.GetCar(expectedResult[0].CarId));
}