public void When_Applies_Discounts_To_Products_And_There_Is_No_Products_Then_Returns_Empty_List() { // Arrange var discounts = new List <ProductCategoryDiscount> { ProductCategoryDiscount }; // Act var result = sut.ApplyDiscountsToProducts(new List <Product>(), discounts); // Assert result.Should().BeEquivalentTo(new List <ApplyDiscountsToProductsResult>()); }
public void ApplyDiscountsToProducts_ForEmptyDiscounts_NotReturnsNull() { // arrange var products = new List <Product> { new Product("", "", 35, "", "", true, "", "") }; var discounts = new List <ProductCategoryDiscount>(); var sut = new ProductCategoryDiscountQueryService(categoryDiscountRepository.Object, productCategoryRepository.Object, discountCategoryRepository.Object, mapper.Object); // act var result = sut.ApplyDiscountsToProducts(products, discounts); // assert result.Should().NotBeNull(); }
public void ApplyDiscountToProducts_ReturnProductsIfDifferentDiscount() { // arrange var data = PrepareProductsWithDiscounts(); // product and discount are not joined var products = data.Item1; var discounts = data.Item2; // act var sut = new ProductCategoryDiscountQueryService(categoryDiscountRepository.Object, productCategoryRepository.Object, discountCategoryRepository.Object, mapper.Object); var result = sut.ApplyDiscountsToProducts(products, discounts); var productsWithoutDiscounts = result.Where(s => s.Item2 == null); // assert productsWithoutDiscounts.Count().Should().Be(1); }
public void ApplyDiscountToProducts_WhenAreDiscounts_ReturnValidPairs() { // arrange var(products, discounts) = PrepareProductsWithDiscounts(); var expected = new List <(int, ProductCategoryDiscount)> { (products[0].Id, discounts[0]), (products[1].Id, discounts[0]), (products[2].Id, discounts[1]), (products[3].Id, null) }; // act var sut = new ProductCategoryDiscountQueryService(categoryDiscountRepository.Object, productCategoryRepository.Object, discountCategoryRepository.Object, mapper.Object); var result = sut.ApplyDiscountsToProducts(products, discounts); // assert result.Count.Should().Be(products.Count); result.Should().BeEquivalentTo(expected); }