示例#1
0
        public void TestDeleteModels_ReturnedTrue()
        {
            //Arrange
            _assetModelsRepository.Setup(x => x.DeleteModels(It.IsAny <int>())).Returns(true);
            //Act
            var isDeleted = _ModelsController.Delete(1);

            //Assert
            Assert.IsTrue(isDeleted);
        }
示例#2
0
        public async void DeleteModel_ReturnModelDeleted(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);

            // Act
            var result = await controller.Delete(id);

            // Assert
            Assert.IsType <NoContentResult>(result);
        }