public void GetTruckList_Ok_Result() { var controller = new TruckController(repo); var data = controller.Index(); ViewResult result = data as ViewResult; Assert.IsInstanceOfType(result.Model, typeof(List <TruckViewModel>)); }
public async Task Index_ListTrucks() { var mockServices = new Mock <ITruckService>(); var modelServices = new Mock <IModelService>(); var unitOfWork = new Mock <IUnitOfWork>(); mockServices.Setup(x => x.ListAllTrucks()).ReturnsAsync(ListTrucks()); var controller = new TruckController(unitOfWork.Object, mockServices.Object, modelServices.Object); var result = await controller.Index(); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <List <TruckDTO> >(viewResult.ViewData.Model); Assert.Equal(2, model.Count); }