public void Delete_IdExisting_ReturnsDeletedProductStockWithSpecifiedId() { //Arrange int existingId = 12; ProductStock expected = new ProductStock { Id = existingId, Product = new Product { Id = 5 }, ProductSize = new ProductSize { Id = 3 }, Quantity = 94 }; Mock <IProductStockRepository> productStockRepository = new Mock <IProductStockRepository>(); productStockRepository.Setup(repo => repo.Delete(existingId)). Returns(expected); Mock <IProductRepository> productRepository = new Mock <IProductRepository>(); Mock <IProductSizeRepository> productSizeRepository = new Mock <IProductSizeRepository>(); IProductStockService productStockService = new ProductStockService(productStockRepository.Object, productRepository.Object, productSizeRepository.Object); //Act ProductStock actual = productStockService.Delete(existingId); //Assert Assert.Equal(expected, actual); }
public void Delete_IdNonExisting_ReturnsNull() { //Arrange int nonExistingId = 12; ProductStock expected = null; Mock <IProductStockRepository> productStockRepository = new Mock <IProductStockRepository>(); productStockRepository.Setup(repo => repo.Delete(nonExistingId)). Returns(expected); Mock <IProductRepository> productRepository = new Mock <IProductRepository>(); Mock <IProductSizeRepository> productSizeRepository = new Mock <IProductSizeRepository>(); IProductStockService productStockService = new ProductStockService(productStockRepository.Object, productRepository.Object, productSizeRepository.Object); //Act ProductStock actual = productStockService.Delete(nonExistingId); //Assert Assert.Equal(expected, actual); }