Exemplo n.º 1
0
        public void TestDetermineInvoiceCurrencyForFailure()
        {
            for (int i = 0; i < files.Length; i++)
            {
                var assembly     = Assembly.GetExecutingAssembly();
                var resourceName = resourceLocation + "." + files[i];

                using (var stream = assembly.GetManifestResourceStream(resourceName))
                {
                    if (stream != null)
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            var fileContents             = reader.ReadToEnd();
                            var invoiceProcessingContext = new InvoiceProcessingContext();
                            invoiceProcessingContext.Invoice = new Invoice();
                            invoiceProcessingContext.Text    = fileContents;

                            var tasks = new List <IInvoiceProcessingTask>();
                            tasks.Add(new AnalyzeEntities(1));
                            tasks.Add(new DetermineInvoiceCurrency());
                            InvoiceProcessingTaskExecutionHelper.ExecuteTasks(invoiceProcessingContext, tasks);

                            Assert.AreNotEqual(invoiceCurrency[i], Convert.ToString(invoiceProcessingContext.Invoice.Currency));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void TestDetermineInvoiceTotalAmountTaskForFailure()
        {
            var invoiceProcessingContext = new InvoiceProcessingContext();

            invoiceProcessingContext.Invoice = new Invoice();
            invoiceProcessingContext.Text    = "Some Random Text";
            (new DetermineInvoiceTotalAmountTask()).Execute(invoiceProcessingContext);
            (new DetermineInvoiceAmountDueTask()).Execute(invoiceProcessingContext);

            invoiceProcessingContext.Text = "Some Random Text $100 $200 $300 $400 Some Random Text";

            (new DetermineInvoiceTotalAmountTask()).Execute(invoiceProcessingContext);
            (new DetermineInvoiceAmountDueTask()).Execute(invoiceProcessingContext);
            Assert.IsTrue(true);
        }
Exemplo n.º 3
0
        public void TestAnalyzeEntitiesTimeOut()
        {
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = resourceLocation + "." + files[0];

            using (var stream = assembly.GetManifestResourceStream(resourceName))
            {
                if (stream != null)
                {
                    using (var reader = new StreamReader(stream))
                    {
                        var fileContents             = reader.ReadToEnd();
                        var invoiceProcessingContext = new InvoiceProcessingContext();
                        invoiceProcessingContext.Invoice = new Invoice();
                        invoiceProcessingContext.Text    = fileContents;

                        var tasks = new List <IInvoiceProcessingTask>();
                        tasks.Add(new AnalyzeEntities(10));
                        InvoiceProcessingTaskExecutionHelper.ExecuteTasks(invoiceProcessingContext, tasks);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void TestDetermineInvoiceTotalAmountTaskForAmountDue()
        {
            for (int i = 0; i < files.Length; i++)
            {
                var assembly     = Assembly.GetExecutingAssembly();
                var resourceName = resourceLocation + "." + files[i];

                using (var stream = assembly.GetManifestResourceStream(resourceName))
                {
                    if (stream != null)
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            var fileContents             = reader.ReadToEnd();
                            var invoiceProcessingContext = new InvoiceProcessingContext();
                            invoiceProcessingContext.Invoice = new Invoice();
                            invoiceProcessingContext.Text    = fileContents;
                            (new DetermineInvoiceAmountDueTask()).Execute(invoiceProcessingContext);
                            Assert.AreEqual(Convert.ToDecimal(amountDue[i]), Convert.ToDecimal(invoiceProcessingContext.Invoice.AmountDue));
                        }
                    }
                }
            }
        }