コード例 #1
0
        public void CartModel_CanCheckout_IfAllItemsCanBeBoughtThenReturnsTrue()
        {
            var cartItem  = new CartItemBuilder().CanBuy().Build();
            var cartModel = new CartModelBuilder().WithItems(cartItem).Build();

            var canCheckout = cartModel.CanCheckout;

            canCheckout.Should().BeTrue();
        }
        private static CartItemData GetCartItemData(decimal basePrice)
        {
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(basePrice)
                .WithTaxPercentage(TaxPercentage)
                .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountPercentage(10).Build();

            return(cartItemData);
        }
コード例 #3
0
        public void PriceShouldBeCalculatedCorrectly(bool taxesEnabled, PriceLoadingMethod priceLoadingMethod,
            TaxCalculationMethod taxCalculationMethod,
            double basePrice, int quantity, double expected)
        {
            var pricingMethod =
                new ProductPricingMethodBuilder().TaxesEnabled(taxesEnabled)
                    .WithPriceLoadingMethod(priceLoadingMethod)
                    .WithTaxCalculationMethod(taxCalculationMethod).Build();
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(Convert.ToDecimal(basePrice))
                    .WithTaxPercentage(Convert.ToDecimal(TaxPercentage))
                    .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithQuantity(quantity).Build();

            pricingMethod.GetPrice(cartItemData).Should().Be(Convert.ToDecimal(expected));
        }
        private void DiscountApplicationOnPricePreTaxIsCorrectForSingleRowPriced(decimal basePrice,
                                                                                 PriceLoadingMethod priceLoadingMethod, DiscountOnPrices discountOnPrices,
                                                                                 ApplyCustomerTax applyCustomerTax, double expected)
        {
            var pricingMethod =
                new ProductPricingMethodBuilder().WithPriceLoadingMethod(priceLoadingMethod)
                .CalculateTaxOnRow()
                .WithDiscountOnPrices(discountOnPrices)
                .WithCustomerTaxApplication(applyCustomerTax)
                .Build();
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(basePrice)
                .WithTaxPercentage(TaxPercentage)
                .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountAmount(1).Build();

            pricingMethod.GetPricePreTax(cartItemData).Should().Be(Convert.ToDecimal(expected));
        }
コード例 #5
0
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
            foreach (var property in builder.Model.GetEntityTypes().SelectMany(t => t.GetProperties()).Where(p => p.ClrType == typeof(decimal)))
            {
                property.Relational().ColumnType = "decimal(18, 2)";
            }
            var brandBuilder            = new BrandBuilder(builder.Entity <Brand>());
            var colorBuilder            = new ColorBuilder(builder.Entity <Color>());
            var fileBuilder             = new FileBuilder(builder.Entity <File>());
            var languageBuilder         = new LanguageBuilder(builder.Entity <Language>());
            var pageBuilder             = new PageBuilder(builder.Entity <Page>());
            var postBuilder             = new PostBuilder(builder.Entity <Post>());
            var postCategoryBuilder     = new PostCategoryBuilder(builder.Entity <PostCategory>());
            var postPostCategoryBuilder = new PostPostCategoryBuilder(builder.Entity <PostPostCategory>());
            var productBuilder          = new ProductBuilder(builder.Entity <Product>());
            var productCategoryBuilder  = new ProductCategoryBuilder(builder.Entity <ProductCategory>());
            var productColorBuilder     = new ProductColorBuilder(builder.Entity <ProductColor>());
            var productPhotoBuilder     = new ProductPhotoBuilder(builder.Entity <ProductPhoto>());
            var reviewBuilder           = new ReviewBuilder(builder.Entity <Review>());
            var slideBuilder            = new SlideBuilder(builder.Entity <Slide>());
            var sliderBuilder           = new SliderBuilder(builder.Entity <Slider>());
            var advertisementBuilder    = new AdvertisementBuilder(builder.Entity <Advertisement>());
            var storeBuilder            = new StoreBuilder(builder.Entity <Store>());
            var storeBrandBuilder       = new StoreBrandBuilder(builder.Entity <StoreBrand>());
            var wishlistBuilder         = new WishlistBuilder(builder.Entity <Wishlist>());
            var orderBuilder            = new OrderBuilder(builder.Entity <Order>());
            var orderItemBuilder        = new OrderItemBuilder(builder.Entity <OrderItem>());
            var addressBuilder          = new AddressBuilder(builder.Entity <Address>());
            var cityBuilder             = new CityBuilder(builder.Entity <City>());
            var countryBuilder          = new CountryBuilder(builder.Entity <Country>());
            var couponBuilder           = new CouponBuilder(builder.Entity <Coupon>());
            var districtBuilder         = new DistrictBuilder(builder.Entity <District>());
            var productQuestionBuilder  = new ProductQuestionBuilder(builder.Entity <ProductQuestion>());
            var questionCategoryBuilder = new QuestionCategoryBuilder(builder.Entity <QuestionCategory>());
            var shipperBuilder          = new ShipperBuilder(builder.Entity <Shipper>());
            var cartBuilder             = new CartBuilder(builder.Entity <Cart>());
            var cartItemBuilder         = new CartItemBuilder(builder.Entity <CartItem>());

            // data seeding
            ApplicationDbContextSeed.Seed(builder);
        }
コード例 #6
0
        private void DiscountApplicationOnPricePreTaxIsCorrectForIndividuallyPriced(decimal basePrice,
                                                                                    PriceLoadingMethod priceLoadingMethod, DiscountOnPrices discountOnPrices,
                                                                                    ApplyCustomerTax applyCustomerTax, double expected)
        {
            var pricingMethod =
                new ProductPricingMethodBuilder().WithPriceLoadingMethod(priceLoadingMethod)
                .CalculateTaxOnIndividualItem()
                .WithDiscountOnPrices(discountOnPrices)
                .WithCustomerTaxApplication(applyCustomerTax)
                .Build();
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(basePrice)
                .WithTaxPercentage(TaxPercentage)
                .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountPercentage(10).Build();

            //check for various quantities - should be fine with individual item pricing to just multiply up
            for (int quantity = 1; quantity <= 10; quantity++)
            {
                cartItemData.Quantity = quantity;
                pricingMethod.GetPricePreTax(cartItemData).Should().Be(Convert.ToDecimal(expected * quantity));
            }
        }