Beispiel #1
0
        private void btnDownload1_Click(object sender, RoutedEventArgs e)
        {
            string sourcefilePath      = ConfigurationManager.AppSettings["InvoiceFilePath"] + tbInvoiceDate1.Text + ".xml";
            string destinationFilePath = @"C:\Invoices\Downloads\" + tbInvoiceDate1.Text + ".xml";

            InvoiceFileService.DownloadInvoiceFile("", sourcefilePath, destinationFilePath);
        }
Beispiel #2
0
        public void SaveInvoiceFile_CorrectFilePath_FileSaved()
        {
            Invoice invoice = new Invoice();

            InvoiceFileService.SaveInvoiceFile(invoice);

            Assert.True(File.Exists(invoice.GetFilePath()));
        }
Beispiel #3
0
        public void DownloadInvoiceFile_FileExists_FileDownloaded()
        {
            //Arrange
            string sourceFilePath      = @"C:\Invoices\00000000-0000-0000-0000-000000000000.xml";
            string downloadingFilePath = @"C:\Invoices\Downloads\00000000-0000-0000-0000-000000000000.xml";

            //Act
            InvoiceFileService.DownloadInvoiceFile("", sourceFilePath, downloadingFilePath);

            //Assert
            Assert.True(File.Exists(downloadingFilePath));
        }
Beispiel #4
0
        public void SaveInvoiceFile_IncorrectFilePath_FileUnsaved()
        {
            Invoice invoice = new Invoice();

            invoice.SetFilePath(@"Wrong\path.wrongpath.xml/wrongpath");

            try
            {
                InvoiceFileService.SaveInvoiceFile(invoice);
            }
            catch { }

            var filPath = invoice.GetFilePath();

            Assert.False(File.Exists(filPath));
        }
Beispiel #5
0
        public void DownloadInvoiceFile_WrongInvoiceId_ExceptionOccured()
        {
            //Arrange
            string    sourceFilePath      = @"C:\Invoices\wrongid.xml";
            string    downloadingFilePath = @"C:\Invoices\Downloads\00000000-0000-0000-0000-000000000000.xml";
            Exception expectedException   = null;

            //Act
            try
            {
                InvoiceFileService.DownloadInvoiceFile("", sourceFilePath, downloadingFilePath);
            }
            catch (Exception ex)
            {
                expectedException = ex;
            }

            //Assert
            Assert.NotNull(expectedException);
        }
Beispiel #6
0
        public void DownloadInvoiceFile_WrongInvoiceId_CorrectExceptionOccured()
        {
            //Arrange
            string    sourceFilePath        = @"C:\Invoices\wrongid.xml";
            string    downloadingFilePath   = @"C:\Invoices\Downloads\00000000-0000-0000-0000-000000000000.xml";
            Exception expectedException     = null;
            var       fileNotFoundException = new FileNotFoundException();

            //Act
            try
            {
                InvoiceFileService.DownloadInvoiceFile("", sourceFilePath, downloadingFilePath);
            }
            catch (Exception ex)
            {
                expectedException = ex;
            }

            //Assert
            Assert.Equal(expectedException.GetType(), fileNotFoundException.GetType());
        }
Beispiel #7
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();
            }
        }
Beispiel #8
0
 public void SaveFile()
 {
     InvoiceFileService.SaveInvoiceFile(this);
 }