예제 #1
0
        private void Seed()
        {
            using var context = new DataContext(ContextOptions);
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            var addresses = FactoryService.CreateBatchOfAddresses();

            context.Addresses.AddRange(addresses);

            var customers = FactoryService.CreateBatchOfCustomers();

            context.Customers.AddRange(customers);

            var invoice = FactoryService.CreateInvoice();

            context.Invoices.AddRange(invoice);

            var newInstalls = new NewInstall()
            {
                Id       = 1,
                Customer = customers.FirstOrDefault(),
                Door     = new RollerShutterDoor()
            };

            context.NewInstalls.AddRange(newInstalls);

            context.SaveChanges();
        }
예제 #2
0
        public void PrepareInvoiceHtmlToPdf_ReturnsFileNotFoundException()
        {
            using var context = new DataContext(ContextOptions);
            var    invoiceService = FactoryService.CreateInvoiceServiceWithFileNotFound(context);
            var    invoice        = FactoryService.CreateInvoice();
            var    customer       = FactoryService.CreateCustomer();
            string path           = string.Empty;

            Assert.Throws <FileNotFoundException>(() => invoiceService.PrepareInvoiceHtmlToPdf(invoice, customer, It.IsAny <string>()));
        }
예제 #3
0
        public void PrepareInvoiceHtmlToPdf_ReturnsHtmlString_WithReplacedText()
        {
            using var context = new DataContext(ContextOptions);
            var    invoiceService = FactoryService.CreateInvoiceService(context);
            var    invoice        = FactoryService.CreateInvoice();
            var    customer       = FactoryService.CreateCustomer();
            string name           = "{{invoiceitems.name}}";
            string price          = "{{invoiceitems.price}}";
            string subtotal       = "{{subtotal}}";
            string vattotal       = "{{vattotal}}";
            string total          = "{{total}}";

            string result = invoiceService.PrepareInvoiceHtmlToPdf(invoice, customer, It.IsAny <string>());

            Assert.DoesNotContain(name, result);
            Assert.DoesNotContain(price, result);
            Assert.DoesNotContain(subtotal, result);
            Assert.DoesNotContain(vattotal, result);
            Assert.DoesNotContain(total, result);
        }