public void GetVatPercent_ThrowsException_GivenSellerIsFromNonEuCountry() { var nonEuCountry = CountriesData.NonEuCountry1; var countryResolver = Substitute.For <ICountryResolver>(); countryResolver.GetCountry(nonEuCountry.CountryCode).Returns(nonEuCountry); var seller = new Company(nonEuCountry.CountryCode, countryResolver); var customer = Substitute.For <LegalEntity>("SomeCountry", countryResolver); var billGenerator = new VatBillGenerator(seller, customer); Assert.Throws <InvalidOperationException>(() => billGenerator.GetVatPercent()); }
public void GetVatPercent_ReturnsCorrectResult_GivenVariousCustomers(bool isSellerVatPayer, Country sellerCountry, bool isCustomerVatPayer, Country customerCountry, decimal expectedVatPercent) { var countryResolver = Substitute.For <ICountryResolver>(); countryResolver.GetCountry(sellerCountry.CountryCode).Returns(sellerCountry); countryResolver.GetCountry(customerCountry.CountryCode).Returns(customerCountry); var seller = new Company(sellerCountry.CountryCode, countryResolver) { IsVatPayer = isSellerVatPayer, CompanyName = "UAB Pardavėjas" }; var customerCompany = new Company(customerCountry.CountryCode, countryResolver) { IsVatPayer = isCustomerVatPayer, CompanyName = "UAB Klientas" }; var customerPerson = new Person(customerCountry.CountryCode, countryResolver) { IsVatPayer = isCustomerVatPayer, FirstName = "Vardenis", FamilyName = "Pavardenis" }; // Ensure VAT is the same for both types of customer (Company/Person) var billGenerator = new VatBillGenerator(seller, customerCompany); billGenerator.GetVatPercent().Should().Be(expectedVatPercent); billGenerator.GenerateBill(100).Should().Contain($"VAT: {expectedVatPercent:0.##}%"); billGenerator = new VatBillGenerator(seller, customerPerson); billGenerator.GetVatPercent().Should().Be(expectedVatPercent); billGenerator.GenerateBill(100).Should().Contain($"VAT: {expectedVatPercent:0.##}%"); }