public ActionResult Create([Bind(Include = "INV_ID_INVOICE,INV_DES_SERIE,INV_DES_FOLIO,INV_FH_FECHA,INV_DES_TOTAL,INV_DES_LUGAR_EXPEDICION,INV_DES_EMISOR_RFC,INV_DES_EMISOR_NOMBRE,INV_DES_UUID")] Invoice invoice) { if (ModelState.IsValid) { invoice.INV_FH_FECHA = DateTime.Now; if (db.Create(invoice)) return RedirectToAction("Index"); } return View(invoice); }
public async Task CreateInvoice_WhenInvoiceValid_ReturnsInvoice(Func <string, InvoicingContext> factory) { //Arrange using (var context = factory(nameof(CreateInvoice_WhenInvoiceValid_ReturnsInvoice))) { var nextInvoiceId = await context.GetNextInvoiceId(); var invoice = new Invoice { InvoiceId = nextInvoiceId, Identifier = "INV-" + nextInvoiceId, UpdatedBy = "Test" }; var sut = new InvoicesRepository(context); //Act await sut.Create(invoice); //Assert invoice.Should().NotBeNull(); invoice.InvoiceId.Should().BeGreaterThan(0); } }