public void Delete_IdExisting_ReturnsDeletedProductSizeWithSpecifiedId() { //Arrange int existingId = 12; ProductSize expected = new ProductSize { Id = existingId, ProductMetric = new ProductMetric { Id = 1 }, Size = "XL", MetricXValue = 70, MetricYValue = -13, MetricZValue = 20 }; Mock <IProductSizeRepository> productSizeRepository = new Mock <IProductSizeRepository>(); productSizeRepository.Setup(repo => repo.Delete(existingId)). Returns(expected); Mock <IProductMetricRepository> productMetricRepository = new Mock <IProductMetricRepository>(); IProductSizeService productSizeService = new ProductSizeService(productSizeRepository.Object, productMetricRepository.Object); //Act ProductSize actual = productSizeService.Delete(existingId); //Assert Assert.Equal(expected, actual); }
public void Delete_IdNonExisting_ReturnsNull() { //Arrange int existingId = 12; ProductSize expected = null; Mock <IProductSizeRepository> productSizeRepository = new Mock <IProductSizeRepository>(); productSizeRepository.Setup(repo => repo.Delete(existingId)). Returns(expected); Mock <IProductMetricRepository> productMetricRepository = new Mock <IProductMetricRepository>(); IProductSizeService productSizeService = new ProductSizeService(productSizeRepository.Object, productMetricRepository.Object); //Act ProductSize actual = productSizeService.Delete(existingId); //Assert Assert.Equal(expected, actual); }