Beispiel #1
0
        public void ReceiptToStringHasEntriesSalesTaxesAndTotal()
        {
            const string  article1Name  = "Article ABC";
            const decimal article1Price = 32.54M;
            const string  article2Name  = "Article ABC";
            const decimal article2Price = 32.54M;
            var           article1      = new Article(1, Country.Usa, Category.ArtsAndCrafts, article1Name, article1Price);
            var           article2      = new Article(1, Country.Usa, Category.Baby, article2Name, article2Price);
            var           receipt       = new Receipt();
            var           tax           = new NoBasicTax();
            var           item1         = new Item(Country.Ita, article1, 1, tax);
            var           item2         = new Item(Country.Ita, article2, 1, tax);

            receipt.Add(item1);
            receipt.Add(item2);
            var entry1 = new Entry(item1);
            var entry2 = new Entry(item2);
            var sb     = new StringBuilder();

            sb.AppendLine(entry1.ToString());
            sb.AppendLine(entry2.ToString());
            sb.AppendLine($"Sales Taxes: {receipt.Taxes}");
            sb.AppendLine($"Total: {receipt.Total}");
            Assert.Equal(sb.ToString(), receipt.ToString());
        }
Beispiel #2
0
        public void NoTaxesOnCheckoutForLocalBasicTaxExemptArticles(int n)
        {
            var checkoutCountry = Country.Ita;
            var supplierCountry = checkoutCountry;
            var categories      = new[] { Category.Books, Category.Food, Category.Medical };
            var expectedTax     = new NoBasicTax();

            CheckReceiptTaxedPrice(n, categories, supplierCountry, checkoutCountry, expectedTax);
        }
Beispiel #3
0
        public void ReceiptGroupsByArticle()
        {
            var article  = new Article(1, Country.Ita, Category.ArtsAndCrafts, Guid.NewGuid().ToString(), 100);
            var tax      = new NoBasicTax();
            var purchase = new Purchase(article.SupplierCountry);

            purchase.Add(article, 2, tax);
            var receipt = purchase.BuildReceipt();

            Assert.Single(receipt.Entries);
        }
Beispiel #4
0
        public void EntryToStringFormatIsQuantityImportedIfApplicableNameColonPrice()
        {
            const string  articleName         = "Article ABC";
            const decimal articlePrice        = 32.54M;
            const int     quantity            = 2;
            const decimal totalPriceWithTaxes = quantity * articlePrice;
            var           article             = new Article(1, Country.Usa, Category.ArtsAndCrafts, articleName, articlePrice);
            var           tax = new NoBasicTax();

            var localPurchase = new Purchase(Country.Usa);

            localPurchase.Add(article, quantity, tax);
            var localReceipt = localPurchase.BuildReceipt();

            var importedPurchase = new Purchase(Country.Ita);

            importedPurchase.Add(article, quantity, tax);
            var importedReceipt = importedPurchase.BuildReceipt();

            Assert.Equal($"{quantity} {articleName}: {totalPriceWithTaxes}", localReceipt.Entries.Single().ToString());
            Assert.Equal($"{quantity} imported {articleName}: {totalPriceWithTaxes}", importedReceipt.Entries.Single().ToString());
        }