Пример #1
0
        public void CreateInvoice_CalculatesPreTaxTotal(int product1Count, int product2Count, int product3Count, int product4Count, double expectedTotal)
        {
            var markdown = MarkdownProvider.GetMarkdown(DateRange.Active, 0.10m);
            var special  = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active, 2, 1, 50m);

            var product1 = new Product("product", Money.USDollar(1m), SellByType.Unit);
            var product2 = new Product("product with markdown", Money.USDollar(1m), SellByType.Unit)
            {
                Markdown = markdown
            };
            var product3 = new Product("product with special", Money.USDollar(1m), SellByType.Unit)
            {
                Special = special
            };
            var product4 = new Product("product with markdown and special", Money.USDollar(1m), SellByType.Unit)
            {
                Markdown = markdown, Special = special
            };

            PopulateOrder(product1, product1Count);
            PopulateOrder(product2, product2Count);
            PopulateOrder(product3, product3Count);
            PopulateOrder(product4, product4Count);

            _order.Invoice.PreTaxTotal.Amount.Should().Be((decimal)expectedTotal);
        }
Пример #2
0
        public static IEnumerable <object[]> MarkdownsSpecialsAndExpectedLineItems()
        {
            var special  = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active, 2, 1, 50m);
            var markdown = MarkdownProvider.GetMarkdown(DateRange.Active, 0.1m);

            yield return(new object[] { null, special, 3, 0, 0 });

            yield return(new object[] { markdown, special, 3, 0, 0 });

            yield return(new object[] { markdown, special, 5, 2, -0.2m });
        }
        public static ICollection <Product> GetOneOfEachProduct(decimal retailPriceAmount = 1m, decimal markdownAmount = 0.5m)
        {
            var retailPrice = Money.USDollar(retailPriceAmount);
            var markdown    = Money.USDollar(markdownAmount);

            /// <remarks>
            /// code:
            ///     E, W - eaches/weighted product
            ///     M - markdown
            ///     S - special
            ///     nM, nS - invalid (expired/future) markdown/special
            /// </remarks>
            return(new List <Product>
            {
                new Product("E", retailPrice, SellByType.Unit),
                new Product("E M", retailPrice, SellByType.Unit)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Active, markdownAmount)
                },
                new Product("E nM", retailPrice, SellByType.Unit)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Expired, markdownAmount)
                },
                new Product("E S", retailPrice, SellByType.Unit)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active)
                },
                new Product("E nS", retailPrice, SellByType.Unit)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Expired)
                },
                new Product("W", retailPrice, SellByType.Weight),
                new Product("W M", retailPrice, SellByType.Weight)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Active, markdownAmount)
                },
                new Product("W nM", retailPrice, SellByType.Weight)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Expired, markdownAmount)
                },
                new Product("W S", retailPrice, SellByType.Weight)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active)
                },
                new Product("W nS", retailPrice, SellByType.Weight)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Expired)
                }
            });
        }
Пример #4
0
        public static IEnumerable <object[]> InvalidDiscountProducts()
        {
            var product = new Product("test product", Money.USDollar(1m), SellByType.Unit);

            yield return(new object[] { product });

            product.Markdown = MarkdownProvider.GetMarkdown(DateRange.Expired);
            yield return(new object[] { product });

            product.Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Expired);
            yield return(new object[] { product });

            product.Markdown = null;
            yield return(new object[] { product });
        }
Пример #5
0
        public static IEnumerable <object[]> SpecialsAndExpectedLineItems()
        {
            yield return(new object[] { 1, SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active, 2, 1, 50m), 3, 1, -0.5m });

            yield return(new object[] { 2, SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active, 2, 3, 10m), 10, 2, -1.2m });
        }