Ejemplo n.º 1
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>()));
        }
        public async Task AddorUpdate_AddNewCustomer_ReturnsCustomer()
        {
            using var context = new DataContext(ContextOptions);
            var newCustomer     = FactoryService.CreateCustomer();
            var customerService = FactoryService.CreateCustomerService(context);
            var customer        = await customerService.AddorUpdate(newCustomer);

            Assert.Equal("Customer Four", customer.Name);
            Assert.True(customer.Id > 0);
        }
Ejemplo n.º 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);
        }