コード例 #1
0
        private Invoice GetInvoice()
        {
            var invoice = new Invoice(_mockTaxesService);

            invoice.AddLineItem(new InvoiceItem(3, 15.00M));
            invoice.AddLineItem(new InvoiceItem(4, 10.00M));
            invoice.AddLineItem(new InvoiceItem(5, 2.00M));
            return(invoice);
        }
コード例 #2
0
        private Invoice CreateInvoiceToMerge()
        {
            var invoiceToMerge = new Invoice();

            invoiceToMerge.AddLineItem(_orangeLineItem);
            invoiceToMerge.AddLineItem(new InvoiceLine
            {
                InvoiceLineId = 3,
                Cost          = 6.27m,
                Quantity      = 3,
                Description   = "Blueberries"
            });
            return(invoiceToMerge);
        }
コード例 #3
0
        public void InvoiceAddLineItemEventAddsLineItem()
        {
            _mockInvoiceView.GetCustomer += null;
            LastCall.IgnoreArguments();
            _mockInvoiceView.AddInvoiceLine += null;
            var addInvoiceLineEventRaiser = LastCall.IgnoreArguments().GetEventRaiser();

            _mockInvoiceView.CalculateTotals += null;
            LastCall.IgnoreArguments();
            _mockInvoiceView.SaveInvoice += null;
            LastCall.IgnoreArguments();

            const int     quantity     = 3;
            const decimal amount       = 35.00M;
            ITaxesService taxesService = new TaxesService();

            Expect.Call(_mockInvoiceView.Quantity).Return(quantity);
            Expect.Call(_mockInvoiceView.Amount).Return(amount);
            Expect.Call(_mockTaxesRepository.GetTaxesService()).Return(taxesService);
            var invoiceItem = new InvoiceItem(quantity, amount);
            var invoice     = new Invoice(taxesService);

            invoice.AddLineItem(invoiceItem);
            _mockInvoiceView.InvoiceLineItems = invoice.InvoiceItems;

            _mockRepository.ReplayAll();

            var invoicePresenter = new InvoicePresenter(_mockCustomerRepository, _mockTaxesRepository, _mockInvoiceRepository, _mockInvoiceView);

            addInvoiceLineEventRaiser.Raise(_mockInvoiceView, EventArgs.Empty);
        }
コード例 #4
0
ファイル: Sales.xaml.cs プロジェクト: vijayoommen/StoreApp
        private void AddLineItem_Click(object sender, RoutedEventArgs e)
        {
            var sku   = txtProductcode.Text;
            var units = 0;

            var p = productStore.GetProductBySku(sku);

            if (!int.TryParse(txtUnits.Text, out units) || p == null)
            {
                Clear();
                return;
            }

            var pricingContext = new PricingContext()
            {
                Quantity = units, UnitPrice = p.UnitPrice, Promotion = p.Promotion
            };
            var price = priceCalculator.GetCalculator(p.Promotion.PromotionType).Calculate(pricingContext);

            lineItems.Add(new LineItem()
            {
                ProductName = p.Name, Units = units, UnitPrice = p.UnitPrice, Discount = price.Description, TotalPrice = price.PromoPrice
            });

            invoice.AddLineItem(p.Name, units, p.UnitPrice, price.Description, price.PromoPrice);

            Clear();
        }
コード例 #5
0
        public void GivenAnInvoiceWhenGeneratingThenAddAnInvoiceLine()
        {
            _invoice.AddLineItem(_appleLineItem);

            var expectedLineItems = new List <InvoiceLine> {
                _appleLineItem
            };

            _invoice.LineItems.Should().BeEquivalentTo(expectedLineItems);
        }