public async Task CanGetFinalProductPriceWithDiscount() { var product = await _productService.GetProductBySkuAsync("BP_20_WSP"); var customer = await _customerService.GetCustomerByEmailAsync(NopTestsDefaults.AdminEmail); var mapping = new DiscountProductMapping { DiscountId = 1, EntityId = product.Id }; await _productService.InsertDiscountProductMappingAsync(mapping); await _customerService.ApplyDiscountCouponCodeAsync(customer, "123"); //set HasDiscountsApplied property product.HasDiscountsApplied = true; var(finalPriceWithoutDiscounts, finalPrice, _, _) = await _priceCalcService.GetFinalPriceAsync(product, customer); await _productService.DeleteDiscountProductMappingAsync(mapping); await _customerService.RemoveDiscountCouponCodeAsync(customer, "123"); finalPrice.Should().Be(69.99M); finalPriceWithoutDiscounts.Should().Be(79.99M); }
/// <summary> /// Deletes a discount-product mapping record /// </summary> /// <param name="discountProductMapping">Discount-product mapping</param> public virtual void DeleteDiscountProductMapping(DiscountProductMapping discountProductMapping) { if (discountProductMapping is null) { throw new ArgumentNullException(nameof(discountProductMapping)); } _discountProductMappingRepository.Delete(discountProductMapping); }
public void CanGetFinalProductPriceWithDiscount() { var product = _productService.GetProductBySku("BP_20_WSP"); var customer = _customerService.GetCustomerByEmail(NopTestsDefaults.AdminEmail); var mapping = new DiscountProductMapping { DiscountId = 1, EntityId = product.Id }; _productService.InsertDiscountProductMapping(mapping); _customerService.ApplyDiscountCouponCode(customer, "123"); //set HasDiscountsApplied property product.HasDiscountsApplied = true; var finalPrice = _priceCalcService.GetFinalPrice(product, customer); _productService.DeleteDiscountProductMapping(mapping); _customerService.RemoveDiscountCouponCode(customer, "123"); finalPrice.Should().Be(69.99M); }