public void Provider_IS_VAT_Payer_Client_lives_IN_EU_Dont_pay_VAT_Different_countries_return_121() { IInvoiceCalculator calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomLT; var customer = UsersFixture.CustomerInEUSE; var order = new Order(100); var mockIsInEuropeanUnion = Substitute.For <ICountryInfoProvider>(); mockIsInEuropeanUnion.IsInEurope(provider.Country).Returns(true); mockIsInEuropeanUnion.IsInEurope(customer.Country).Returns(true); calculator.CountryProvider = mockIsInEuropeanUnion; var mockVatGetter = Substitute.For <IVatGetter>(); mockVatGetter.GetVAT(provider.Country).Returns(21); mockVatGetter.GetVAT(customer.Country).Returns(25); calculator.VATGetter = mockVatGetter; var result = calculator.Calculate(customer, provider, order); Assert.Equal(121, result); }
public void Provider_IS_VAT_Payer_Client_lives_outside_EU_return_1500() { IInvoiceCalculator calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomDE; var customer = UsersFixture.CustomerOutsideEUJAV; var order = new Order(1500); var mockIsInEuropeanUnion = Substitute.For <ICountryInfoProvider>(); mockIsInEuropeanUnion.IsInEurope(provider.Country).Returns(true); mockIsInEuropeanUnion.IsInEurope(customer.Country).Returns(false); calculator.CountryProvider = mockIsInEuropeanUnion; var mockVatGetter = Substitute.For <IVatGetter>(); mockVatGetter.GetVAT(provider.Country).Returns(19); mockVatGetter.GetVAT(customer.Country).Returns(11); calculator.VATGetter = mockVatGetter; var result = calculator.Calculate(customer, provider, order); Assert.Equal(1500, result); }
public static void Main(string[] args) { // CreateHostBuilder(args).Build().Run(); //var invoice = new IInvoiceCalculator(); Customer customer = new Customer(new Country("JAV"), new Company("Kompanija", true)); Provider provider = new Provider(new Country("LT"), new Company("ProviderCompany", true)); Order order = new Order(15); IInvoiceCalculator invoiceCalulate = new InvoiceCalculator(); invoiceCalulate.CountryProvider = new CountryInfoProvider(); invoiceCalulate.VATGetter = new VATGetter(); invoiceCalulate.Calculate(customer, provider, order); }
public void Provider_IS_VAT_Payer_Client_lives_outside_EU_return_50() { var calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomLT; var customer = UsersFixture.CustomerOutsideEUZE; var order = new Order(50); IVatGetter vat = new VATGetter(); ICountryInfoProvider countryprovider = new CountryInfoProvider(); calculator.CountryProvider = countryprovider; calculator.VATGetter = vat; var result = calculator.Calculate(customer, provider, order); Assert.Equal(50, result); }
public void Provider_IS_VAT_Payer_Client_lives_IN_EU_pay_VAT_Same_countries_return_1210() { IInvoiceCalculator calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomLT; var customer = UsersFixture.CustomerInEULTPayVAT; var order = new Order(1000); IVatGetter vat = new VATGetter(); ICountryInfoProvider countryprovider = new CountryInfoProvider(); calculator.CountryProvider = countryprovider; calculator.VATGetter = vat; var result = calculator.Calculate(customer, provider, order); Assert.Equal(1210, result); }
public void Provider_IS_VAT_Payer_JAV_Client_lives_outside_EUClient_Not_VAT_payer() { IInvoiceCalculator calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomJAV; var customer = UsersFixture.CustomerInEUSE; var order = new Order(1000); IVatGetter vat = new VATGetter(); ICountryInfoProvider countryprovider = new CountryInfoProvider(); calculator.CountryProvider = countryprovider; calculator.VATGetter = vat; var result = calculator.Calculate(customer, provider, order); Assert.Equal(1110, result); }
public void ICalculator_InTerface_Provider_Not_EU_Exception() { IInvoiceCalculator calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomJAV; var customer = UsersFixture.CustomerInEUITPayVAT; var order = new Order(6000); var mockIsInEuropeanUnion = Substitute.For <ICountryInfoProvider>(); mockIsInEuropeanUnion.IsInEurope(provider.Country).Returns(false); mockIsInEuropeanUnion.IsInEurope(customer.Country).Returns(true); calculator.CountryProvider = mockIsInEuropeanUnion; var message = "Not Specified VATGetter"; var exception = Assert.Throws <BussinessException>(() => calculator.Calculate(customer, provider, order)); Assert.Equal(message, exception.Message); }
public void ICalculator_InTerface_Customer_VAT_NOT_fount() { IInvoiceCalculator calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomJAV; var customer = UsersFixture.CustomerNotInList; var order = new Order(6000); ICountryInfoProvider mockIsInEuropeanUnion = new CountryInfoProvider(); calculator.CountryProvider = mockIsInEuropeanUnion; IVatGetter mockVatGetter = new VATGetter(); calculator.VATGetter = mockVatGetter; var message = "VAT were not found, edit your Country VAT list"; var exception = Assert.Throws <BussinessException>(() => calculator.Calculate(customer, provider, order)); Assert.Equal(message, exception.Message); }
public void Provider_NOY_VAT_Payer_150() { var calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomLTNOTVATPayer; var customer = UsersFixture.CustomerOutsideEUZE; var order = new Order(150); var mockIsInEuropeanUnion = Substitute.For <ICountryInfoProvider>(); mockIsInEuropeanUnion.IsInEurope(provider.Country).Returns(false); mockIsInEuropeanUnion.IsInEurope(customer.Country).Returns(true); calculator.CountryProvider = mockIsInEuropeanUnion; var mockVatGetter = Substitute.For <IVatGetter>(); mockVatGetter.GetVAT(provider.Country).Returns(21); mockVatGetter.GetVAT(customer.Country).Returns(25); calculator.VATGetter = mockVatGetter; var result = calculator.Calculate(customer, provider, order); Assert.Equal(150, result); }
public void Provider_IS_VAT_Payer_Client_lives_IN_EU_pay_VAT_Same_countries_return_6000() { IInvoiceCalculator calculator = new InvoiceCalculator(); var provider = UsersFixture.ProviderIsVATPayerFomIT; var customer = UsersFixture.CustomerInEUITPayVAT; var order = new Order(6000); var mockIsInEuropeanUnion = Substitute.For <ICountryInfoProvider>(); mockIsInEuropeanUnion.IsInEurope(provider.Country).Returns(true); mockIsInEuropeanUnion.IsInEurope(customer.Country).Returns(true); calculator.CountryProvider = mockIsInEuropeanUnion; var mockVatGetter = Substitute.For <IVatGetter>(); mockVatGetter.GetVAT(provider.Country).Returns(22); mockVatGetter.GetVAT(customer.Country).Returns(22); calculator.VATGetter = mockVatGetter; var result = calculator.Calculate(customer, provider, order); Assert.NotEqual(6000, result, 0); }