public void T011_BusinessHasSubstractions() { // Given int companyMoney = 23000; List <Goods> goods = new List <Goods>() { new Goods(1000, "keyboard"), new Goods(2000, "mouse") }; // Expected // Right. So, 23000 - 3000 from 'costs of generating the profits' = 20000 // Thus, total tax = 0.19 * 20000 = 3800 int expectedTax = 3800; // Yes, you will have to deal with a new method. You will have to pass appropriate parameters // to the calculator using the CONSTRUCTOR, because you have no other way of // passing without changing the interface of the method - the contract. ITaxCalculator calculator = TaxCalculatorFactory.Create(CustomerType.BusinessLinear, goods); // When int actualTax = calculator.CalculateTax(companyMoney); // Then Assert.AreEqual(expectedTax, actualTax); }
static void Main(string[] args) { // Variables // double basePrice = 10; // double pricePerTopping = 1; PriceDefinition priceDefinition = new PriceDefinition { BasePrice = 10, PricePerUnit = 1 }; TaxCalculatorFactory taxFactory = new TaxCalculatorFactory(); // User input Console.WriteLine("Enter your province and press enter:"); string province = Console.ReadLine(); Console.WriteLine("Enter the number of toppings and press enter:"); string toppings = Console.ReadLine(); // Calculation int numberOfToppings = int.Parse(toppings); var pizza = new Pizza(taxFactory.GetTaxCalculator(province), numberOfToppings, priceDefinition); double total = pizza.CalculatePrice(); // Output Console.WriteLine($"Order total is: {total}"); Console.WriteLine("Press any key to exit"); Console.Read(); }
public void T009_CalculateTotalPersonalTax() { // Given int receivedMoney = 100000; // int taxCredit = 8000; kwota wolna od podatku // int taxLevel = 85528; zmiana progu podatkowego // Once again, you may add a TotalPersonalTaxCalculator class and // swap old PersonalTax with this new one in the factory. // You may note for previous tests it will work like first level tax, but it will let you // CHAIN two calculators. Look at Expected and split money appropriately. // If you don't know what I want from you, call me when you get here. ITaxCalculator calculator = TaxCalculatorFactory.Create(CustomerType.Personal); // Expected // Money up to 85528: calculated like T002, so: 13955.04. But we have int, so 13955. // Money above 85528: 32%. In this case, 4631.04. But we have int, so 4631. // TOTAL: 18586 int expectedTax = 4631; // When int actualTax = calculator.CalculateTax(receivedMoney); // Then Assert.AreEqual(expectedTax, actualTax); }
public void CreateAlbertaTaxCalculator() { var taxCalculatorFactory = new TaxCalculatorFactory(); ITaxCalculator result = taxCalculatorFactory.GetTaxCalculator("AB"); Assert.IsType <AlbertaTaxCalculator>(result); }
public void Test2() { TaxCalculatorFactory taxCalculatorFactory = new TaxCalculatorFactory(); ITaxCalculator result = taxCalculatorFactory.GetCalculator("AB"); Assert.IsType <AlbertaTaxCalculator>(result); }
public Biller GetBiller(string strategy) { TaxCalculatorFactory factory = new TaxCalculatorFactory(); ITaxCalculator taxCal = factory.GetTaxCalculator(strategy); return(new Biller(taxCal)); }
public void SetUp() { var mockTaxCalculationRepository = new MockTaxCalculationRepository(); var taxCalculatorFactory = new TaxCalculatorFactory(mockTaxCalculationRepository); var taxCalculationWorkflow = new TaxCalculationWorkflow(mockTaxCalculationRepository, taxCalculatorFactory); _taxController = new TaxController(taxCalculationWorkflow); }
void Initialize() { country = "Local"; TaxCalculatorFactory factory = new TaxCalculatorFactory(); taxCal = factory.GetTaxCalculator(country); biller = new Biller(taxCal); }
public void T003_SelectTaxCalculatorAsPersonal() { // When ITaxCalculator calculator = TaxCalculatorFactory.Create("personal first tax level"); // Then Assert.IsTrue(calculator is PersonalTaxCalculator); }
public void T004_SelectTaxCalculatorAsBusinessLinear() { // When ITaxCalculator calculator = TaxCalculatorFactory.Create("linear business"); // Then Assert.IsTrue(calculator is LinearTaxCalculator); }
public void SetUp() { _flatRateSettingRepository = new Mock<ITaxRateSettingRepository<FlatRateSetting>>(); _flatValueSettingRepository = new Mock<ITaxRateSettingRepository<FlatValueSetting>>(); _progressiveTaxRateSettingRepository = new Mock<ITaxRateSettingRepository<ProgressiveTaxRateSetting>>(); _taxCalculator = new TaxCalculatorFactory( _flatRateSettingRepository.Object, _flatValueSettingRepository.Object, _progressiveTaxRateSettingRepository.Object); }
public TaxCalculatorTests() { var mockTaxAmountFetcher = new MockTaxAmountFetcher(); _taxCalculatorFactory = new TaxCalculatorFactory( mockTaxAmountFetcher, new MockTaxRateFetcher()); _selfInsuranceFee = new SelfInsuranceFee( mockTaxAmountFetcher.FetchTaxAmount(ETaxAmount.PfrSelfAmount).Result, mockTaxAmountFetcher.FetchTaxAmount(ETaxAmount.FomsSelfAmount).Result); }
public void T005_CustomerAsksForPersonalTax() { // Here, you will have to build a second method of a Factory // Given Customer customer = new Customer(20000, CustomerType.Personal); ITaxCalculator calculator = TaxCalculatorFactory.Create(customer.Type); // When int owed = calculator.CalculateTax(customer.Money); // Then Assert.AreEqual(2160, owed); }
public void ComputeTax_Fail(string postalCode, double annualIncome, double taxAmount) { //Given MockPayRepository mockPayRepository = new MockPayRepository(); var taxCalculatorFactory = new TaxCalculatorFactory(iOptionsMock.Object, taxCalculationTypeOptionMock.Object); var insertCalculatedTaxCommandHandler = new CalculateTaxCommandHandler(taxCalculatorFactory, mockPayRepository); Assert.Throws <ArgumentNullException>(() => insertCalculatedTaxCommandHandler.Handle(new CalculateTaxCommand { AnnualIncome = annualIncome, PostalCode = postalCode })); }
public void T008_CalculatePersonalTaxAbove85528() { // Given int receivedMoney = 100000; // Note: you have to build a NEW ITaxCalculator member - add a new class ITaxCalculator calculator = TaxCalculatorFactory.Create("personal second tax level"); // Expected // Money above 85528: 32%, as this is the second tax level. Forget about tax credit this time. // TOTAL: 32000 int expectedTax = 32000; // When int actualTax = calculator.CalculateTax(receivedMoney); // Then Assert.AreEqual(expectedTax, actualTax); }
public void T012_BusinessHasAmortyzacja() { // Given int companyMoney = 20000; List <Goods> goods = new List <Goods>() { new Goods(10001, "laptop") }; int expectedTax = 3325; ITaxCalculator calculator = TaxCalculatorFactory.Create(CustomerType.BusinessLinear, goods); // When int actualTax = calculator.CalculateTax(companyMoney); // Then Assert.AreEqual(expectedTax, actualTax); }
public void ComputeTax(string postalCode, double annualIncome, double taxAmount) { //Given IPayRepository mockPayRepository = new MockPayRepository(); var taxCalculatorFactory = new TaxCalculatorFactory(iOptionsMock.Object, taxCalculationTypeOptionMock.Object); var command = new CalculateTaxCommandHandler(taxCalculatorFactory, mockPayRepository); //When command.Handle(new CalculateTaxCommand { AnnualIncome = annualIncome, PostalCode = postalCode }); //Then var row = ((MockPayRepository)mockPayRepository).table[0]; Assert.NotNull(row); Assert.AreEqual(postalCode, row.PostalCode); Assert.AreEqual(annualIncome, row.AnnualIncome); Assert.AreEqual(taxAmount, row.TaxAmount); }
/// <summary> /// Initializes a new instance of the <see cref="TaxCalculatorFactoryTests"/> class. /// </summary> public TaxCalculatorFactoryTests() { AppConfig appConfig = AppConfigProvider.AppConfig; _factory = new TaxCalculatorFactory(appConfig); }