public async void QueryModelIdX_ReturnsCorrectModel(int id) { // Arrange var mockRepo = new Mock <IVehicleCatalogRepository>(); mockRepo.Setup(repo => repo.GetModel(id)) .Returns(Task.FromResult <Model.Model>(new Model.Model() { Id = id, Name = $"Model {id}", BrandId = 1 })); var mapper = _dependencyFixture.ServiceProvider.GetService <IMapper>(); var logger = Mock.Of <ILogger <ModelsController> >(); var controller = new ModelsController(mockRepo.Object, mapper, logger); // Act var result = await controller.GetModel(id); // Assert var okResult = Assert.IsType <OkObjectResult>(result); var returnValue = Assert.IsType <ModelForDetail>(okResult.Value); var topModel = returnValue.name; Assert.Equal($"Model {id}", topModel); }
public void GetModelTest() { Assert.IsTrue(controller.GetModel(1).Success); }