public async void UpdateModel_ReturnModelUpdated(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 1", BrandId = 1 })); mockRepo.Setup(repo => repo.SaveAll()) .Returns(Task.FromResult <bool>(true)); var mapper = _dependencyFixture.ServiceProvider.GetService <IMapper>(); var logger = Mock.Of <ILogger <ModelsController> >(); var controller = new ModelsController(mockRepo.Object, mapper, logger); ModelForUpdate newModel = new ModelForUpdate() { name = "Fake" }; // Act var result = await controller.Put(id, newModel); // Assert var okResult = Assert.IsType <CreatedAtRouteResult>(result); var returnValue = Assert.IsType <string>(okResult.Value); Assert.Equal("Model updated.", returnValue); }
public void TestEditingModels_DoesntReturnNull_ReturnsSameTaskTypeID() { //Arrange _assetModelsRepository.Setup( x => x.EditModel(It.IsAny <int>(), It.IsAny <AssetManager_Models>())) .Returns(PutModels_ResultFromPutReturnInt()); //Act var putModelsID = _ModelsController.Put(1, PutModels()); //Assert Assert.IsNotNull(putModelsID, "Result is null"); putModelsID.ShouldBeEquivalentTo(1); }