public async Task Able_to_generate_invoice() { var product = ProductMockBuilder.Build(); var productRepo = Substitute.For <IProductRepository>(); productRepo.Get(Arg.Any <Guid>()).Returns(product); var supplier = SupplierMockBuilder.Build(); var supplierRepo = Substitute.For <ISupplierRepository>(); supplierRepo.Get(Arg.Any <Guid>()).Returns(supplier); var customer = CustomerMockBuilder.Build(); var customerRepo = Substitute.For <ICustomerRepository>(); customerRepo.Get(Arg.Any <Guid>()).Returns(customer); var sut = new InvoiceGenerator(productRepo, supplierRepo, customerRepo); var actual = await sut.Generate(OrderMockBuilder.Build()); actual.Customer.Should().Be(customer); actual.Supplier.Should().Be(supplier); actual.Product.Should().Be(product); actual.Amount.Should().Be(new InvoiceAmount(30, 0.19)); }
public void Able_to_create_instance_with_persistence_constructor() { var expectedId = Guid.NewGuid(); var expectedNumber = "Invoice#"; var expectedCreatedAt = DateTime.UtcNow; var expectedSupplier = SupplierMockBuilder.Build(); var expectedCustomer = CustomerMockBuilder.Build(); var expectedAmount = new InvoiceAmount(30, 0.19); var actual = new Invoice( expectedId, expectedNumber, expectedCreatedAt, _order, _product, expectedSupplier, expectedCustomer, expectedAmount); actual.Id.Should().Be(expectedId); actual.Number.Should().Be(expectedNumber); actual.CreatedAt.Should().Be(expectedCreatedAt); actual.Order.Should().Be(_order); actual.Product.Should().Be(_product); actual.Supplier.Should().Be(expectedSupplier); actual.Customer.Should().Be(expectedCustomer); actual.Amount.Should().NotBeNull(); }
public override async Task Able_to_get_existing_entity() { var supplier = SupplierMockBuilder.Build(); await _sut.Save(supplier); var actual = await _sut.Get(supplier.Id); actual.Should().Be(supplier); }
public void Able_to_calculate_VAT_rate_for_non_VAT_paying_non_EU_supplier(Customer customer) { var supplier = SupplierMockBuilder.Build( address: AddressMockBuilder.BuildMontenegro(), paysVat: false); var invoice = new Invoice( _order, _product, supplier, customer); invoice.Amount.VATRate.Should().Be(0); }
public void Able_to_calculate_VAT_rate_for_VAT_paying_supplier_and_customer_that_live_in_same_country(Customer customer) { var supplier = SupplierMockBuilder.Build( address: AddressMockBuilder.BuildGermany(VATRate: 0.19), paysVat: true); var invoice = new Invoice( _order, _product, supplier, customer); invoice.Amount.VATRate.Should().Be(0.19); }
public void Returns_failure_result_for_VAT_paying_supplier_with_EU_non_VAT_paying_customer_in_same_country() { var supplier = SupplierMockBuilder.Build( address: AddressMockBuilder.BuildGermany(), paysVat: true); var customer = CustomerMockBuilder.Build( address: AddressMockBuilder.BuildGermany(), paysVat: false); var actual = _sut.Execute(supplier, customer); actual.IsSuccess.Should().BeFalse(); actual.Value.Should().Be(0); }
public void Returns_success_result_for_VAT_paying_supplier_with_EU_non_VAT_paying_customer_in_different_country() { var supplier = SupplierMockBuilder.Build( address: AddressMockBuilder.BuildGermany(), paysVat: true); var customer = CustomerMockBuilder.Build( address: AddressMockBuilder.BuildFrance(VATRate: 0.2), paysVat: false); var actual = _sut.Execute(supplier, customer); actual.IsSuccess.Should().BeTrue(); actual.Value.Should().Be(0.2); }
public void Returns_success_result_for_VAT_paying_supplier_with_non_EU_customer() { var supplier = SupplierMockBuilder.Build( address: AddressMockBuilder.BuildGermany(), paysVat: true); var customer = CustomerMockBuilder.Build( address: AddressMockBuilder.BuildMontenegro(), paysVat: true); var actual = _sut.Execute(supplier, customer); actual.IsSuccess.Should().BeTrue(); actual.Value.Should().Be(0); }
public void Able_to_create_instance() { var expectedSupplier = SupplierMockBuilder.Build(); var expectedCustomer = CustomerMockBuilder.Build(); var expectedAmount = new InvoiceAmount(30, 0.19); var actual = new Invoice( _order, _product, expectedSupplier, expectedCustomer); actual.Id.Should().NotBeEmpty(); actual.Number.Should().NotBeNullOrEmpty(); actual.CreatedAt.Should().BeCloseTo(DateTime.UtcNow, precision: 1000); actual.Order.Should().Be(_order); actual.Product.Should().Be(_product); actual.Supplier.Should().Be(expectedSupplier); actual.Customer.Should().Be(expectedCustomer); actual.Amount.Should().Be(expectedAmount); }