public override async Task Able_to_get_existing_entity() { var invoice = InvoiceMockBuilder.Build(); await _sut.Save(invoice); var actual = await _sut.Get(invoice.Id); actual.Should().Be(invoice); }
public void Able_to_map_domain_to_contract_model() { var invoiceId = Guid.NewGuid(); var invoice = InvoiceMockBuilder.Build(id: invoiceId); var actual = invoice.ToContractModel(); var expected = CreateExpectedInvoice(id: invoiceId); actual.Should().BeEquivalentTo(expected); }
public async Task Throws_exception_when_trying_to_save_invoice_wit_existing_order() { var order = OrderMockBuilder.Build(); var firstInvoice = InvoiceMockBuilder.Build(order: order); await _sut.Save(firstInvoice); var secondInvoice = InvoiceMockBuilder.Build(order: order); Func <Task> action = () => _sut.Save(secondInvoice); action.Should().Throw <EntityAlreadyExistsException>() .WithMessage("Invoice already exists."); }
public async Task Able_to_get_invoice() { var invoiceId = Guid.NewGuid(); var invoice = InvoiceMockBuilder.Build(id: invoiceId); var invoiceRepo = Substitute.For <IInvoiceRepository>(); invoiceRepo.Get(Arg.Any <Guid>()).Returns(invoice); var sut = new GetInvoiceUseCase(invoiceRepo); var actual = await sut.Execute(new GetInvoiceRequest()); var expected = CreateExpectedInvoice(id: invoiceId); actual.Should().BeEquivalentTo(expected); }
public async Task Able_to_generate_invoice() { var invoiceId = Guid.NewGuid(); var orderRepo = Substitute.For <IOrderRepository>(); orderRepo.Get(Arg.Any <Guid>()).Returns(OrderMockBuilder.Build()); var invoice = InvoiceMockBuilder.Build(id: invoiceId); var invoiceGen = Substitute.For <IInvoiceGenerator>(); invoiceGen.Generate(Arg.Any <Order>()).Returns(invoice); var invoiceRepo = Substitute.For <IInvoiceRepository>(); var sut = new GenerateInvoiceUseCase(orderRepo, invoiceGen, invoiceRepo); var actual = await sut.Execute(new GenerateInvoiceRequest()); var expected = CreateExpectedInvoice(id: invoiceId); actual.Should().BeEquivalentTo(expected); await invoiceRepo.Received().Save(invoice); }