Example #1
0
        public void SetVatRate_CorrectVatParameter_CorrectVatValue()
        {
            //Arrange
            var invoiceItem = new InvoiceItem();
            int vatParamter = 23;

            //Act
            invoiceItem.SetVatRate(vatParamter);

            //Assert
            Assert.AreEqual(invoiceItem.GetVatRate(), vatParamter);
        }
Example #2
0
        public void CalculateGrossAmount_CorrectVat_CorrectGrossAmount()
        {
            //Arrange
            var invoiceItem = new InvoiceItem();

            invoiceItem.AmountNet = 100;
            invoiceItem.SetVatRate(23);

            //Act
            invoiceItem.CalculateGrossAmount();

            //Assert
            Assert.AreEqual(invoiceItem.AmountGross, 123);
        }
Example #3
0
        public void SetVatRate_IncorrectVatParameter_ExceptionOccured()
        {
            //Arrange
            var       invoiceItem       = new InvoiceItem();
            int       vatParamter       = 120;
            Exception expectedException = null;

            //Act
            try
            {
                invoiceItem.SetVatRate(vatParamter);
            }
            catch (Exception ex)
            {
                expectedException = ex;
            }

            //Assert
            Assert.IsNotNull(expectedException);
        }
Example #4
0
        public void CalculateGrossAmount_IncorrectVat_IncorrectGrossAmount()
        {
            //Arrange
            var       invoiceItem       = new InvoiceItem();
            int       vatParamter       = 120;
            Exception expectedException = null;

            //Act
            try
            {
                invoiceItem.SetVatRate(vatParamter);
            }
            catch (Exception ex)
            {
                expectedException = ex;
            }

            //Assert
            Assert.AreNotEqual(vatParamter, invoiceItem.GetVatRate());
        }
Example #5
0
        public void SetVatRate_IncorrectVatParameter_CorrectExceptionType()
        {
            //Arrange
            var       invoiceItem                 = new InvoiceItem();
            int       vatParamter                 = 120;
            Exception expectedException           = null;
            var       argumentOutOfRangeException = new ArgumentOutOfRangeException();

            //Act
            try
            {
                invoiceItem.SetVatRate(vatParamter);
            }
            catch (Exception ex)
            {
                expectedException = ex;
            }

            //Assert
            Assert.AreEqual(argumentOutOfRangeException.GetType(), expectedException.GetType());
        }
Example #6
0
        private void btnSaveInvoice_Click(object sender, RoutedEventArgs e)
        {
            //  MessageBox.Show("Plik nie istnieje", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);

            Invoice invoice = new Invoice();

            invoice.SellerData = tbSellerData.Text;
            invoice.BuyerData  = tbBuyerData.Text;
            invoice.IssueDate  = tbIssueDate.SelectedDate;

            InvoiceFileService.SaveInvoiceFile(invoice);

            DBService.InsertInvoice(invoice);

            if (!string.IsNullOrEmpty(tbProductName1.Text))
            {
                InvoiceItem invoiceItem = new InvoiceItem()
                {
                    Name      = tbProductName1.Text,
                    AmountNet = Convert.ToDouble(tbAmount1.Text)
                };

                invoiceItem.SetAmountNet(Convert.ToDouble(tbNettoPrice1.Text));
                invoiceItem.SetVatRate(Convert.ToInt32(tbVat1.Text));
                invoiceItem.CalculateGrossAmount();
            }
            if (!string.IsNullOrEmpty(tbProductName2.Text))
            {
                InvoiceItem invoiceItem = new InvoiceItem()
                {
                    Name      = tbProductName2.Text,
                    AmountNet = Convert.ToDouble(tbAmount2.Text)
                };

                invoiceItem.SetAmountNet(Convert.ToDouble(tbNettoPrice2.Text));
                invoiceItem.SetVatRate(Convert.ToInt32(tbVat2.Text));
                invoiceItem.CalculateGrossAmount();
            }
        }
Example #7
0
        public void CalculateTotalGrossAmount_CorrectValuesFiveItems_CorrectTotalGrossAmount()
        {
            //Arrange
            var invoice = new Invoice();

            for (int i = 0; i < 5; i++)
            {
                var invoiceItem = new InvoiceItem()
                {
                    AmountNet = 100,
                    Amount    = 1
                };
                invoiceItem.SetVatRate(23);
                invoiceItem.CalculateGrossAmount();

                invoice.items.Add(invoiceItem);
            }

            //Act
            invoice.CalculateTotalGrossAmount();

            //Assert
            Assert.Equal(615, invoice.TotalGrossAmount);
        }