public void MultipleProducts_Mocks() { // Arrange var cart = A.Fake <ICart>(); A.CallTo(() => cart.Products).Returns(new [] { new ProductToPurchase { ProductId = 1, Quantity = 1 }, new ProductToPurchase { ProductId = 42, Quantity = 7 }, }); IProductCatalog mockProductCatalog = A.Fake <IProductCatalog>(); A.CallTo(() => mockProductCatalog.LookupPrice(1)).Returns(1m); A.CallTo(() => mockProductCatalog.LookupPrice(42)).Returns(1.5m); ITaxCalculator mockTaxCalculator = A.Fake <ITaxCalculator>(); A.CallTo(() => mockTaxCalculator.CalculateTaxes(11.5m)).Returns(1.15m); // Act var calculator = new PricingCalculator(mockProductCatalog, mockTaxCalculator); PricingSummary price = calculator.PriceCart(cart); // Assert Assert.That(price.ProductPrices.Count, Is.EqualTo(2)); Assert.That(price.SubTotal, Is.EqualTo(11.5m)); Assert.That(price.Taxes, Is.EqualTo(1.15m)); Assert.That(price.Total, Is.EqualTo(12.65m)); }
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 Biller GetBiller(string strategy) { TaxCalculatorFactory factory = new TaxCalculatorFactory(); ITaxCalculator taxCal = factory.GetTaxCalculator(strategy); return(new Biller(taxCal)); }
public CheckoutService( ICart cart, ITaxCalculator taxCalculator) { _cart = cart; _taxCalculator = taxCalculator; }
public void InitializeTest() { var mapper = new AutoMapperSetup().CreateAutoMapperConfig(); var configuration = new ConfigurationSetup().CreateConfiguration(); taxCalculator = new TaxCalculatorTaxJarApi(configuration, mapper); }
public void CreateTaxCalculator(string state = "") { _state = state; //This is mapper function, where you can create the actual Tax Class required for the specific State. //We can have a Tax Admin module which can map the concreate tax class with store and store it in a DB. //Here you can use Dictionaly and populate the mapping from DB. //Dictionary<String, ITaxCalculator> objTaxCalculatorRepo = // new Dictionary<string, ITaxCalculator>(); //objTaxCalculatorRepo.Add() //But for the current demo, I am just using If condition. if (_state == "") { _taxCalculator = new BasicTaxCalculator(); } if (_state == "FL" || _state == "NM" || _state == "NV") { _taxCalculator = new PreDiscountTaxCalculator(); } if (_state == "IO") // Let's say Iowa has Item wise tax { _taxCalculator = new ItemWiseTaxCalculator(); } }
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); }
public void testInit() { taxCalculatorObj = new TaxCalculator(); biller = new Biller(taxCalculatorObj); shoppingCartObj = new ShoppingCart(); storeShelf = new StoreShelf(); }
public PriceCalculationService( SmartDbContext db, IWorkContext workContext, IStoreContext storeContext, IPriceCalculatorFactory calculatorFactory, ITaxCalculator taxCalculator, IProductService productService, IProductAttributeMaterializer productAttributeMaterializer, ITaxService taxService, ICurrencyService currencyService, CatalogSettings catalogSettings, TaxSettings taxSettings) { _db = db; _workContext = workContext; _storeContext = storeContext; _calculatorFactory = calculatorFactory; _taxCalculator = taxCalculator; _productService = productService; _productAttributeMaterializer = productAttributeMaterializer; _taxService = taxService; _currencyService = currencyService; _catalogSettings = catalogSettings; _taxSettings = taxSettings; _primaryCurrency = currencyService.PrimaryCurrency; }
public TaxCalculatorService(IEmployeeRepository employeeRepository, ITaxCalculator calculator, IPayslipGenerator generator, ILogger logger) { Repository = employeeRepository; Calculator = calculator; Generator = generator; Logger = logger; }
public void CreateAlbertaTaxCalculator() { var taxCalculatorFactory = new TaxCalculatorFactory(); ITaxCalculator result = taxCalculatorFactory.GetTaxCalculator("AB"); Assert.IsType <AlbertaTaxCalculator>(result); }
public void Run() { Console.WriteLine("Podaj typ podatku: [1] liniowy, [2] progresywny"); var choiceKey = Console.ReadKey(); ITaxCalculator taxCalculator = null; string taxName = null; switch (choiceKey.KeyChar) { case '1': taxCalculator = new LinearTaxCalculator(); taxName = "liniowy"; break; case '2': taxCalculator = new ProgressiveTaxCalculator(); taxName = "progresywny"; break; default: Console.WriteLine(" Nieprawidłowy wybór!"); break; } if (taxCalculator != null) { var getRevenue = new RevenueGet(); double revenue = getRevenue.GetRevenue(); int tax = taxCalculator.CalculateTax(revenue); Console.WriteLine("Podatek {0} za rok: {1}", taxName, tax); } Console.ReadKey(); }
public IActionResult Index(IncomeDetails obj) { ITaxCalculator t = null; switch (obj.Country) { case "USA": t = new TaxCalculatorForUS(); break; case "UK": t = new TaxCalculatorForUK(); break; case "IN": t = new TaxCalulatorForIN(); break; } t.TotalIncome = obj.TotalIncome; t.TotalDeduction = obj.TotalDeduction; TaxCalculator cal = new TaxCalculator(); ViewBag.TotalTax = cal.CalculateTax(t); return(View("Index", obj)); }
public void Test2() { TaxCalculatorFactory taxCalculatorFactory = new TaxCalculatorFactory(); ITaxCalculator result = taxCalculatorFactory.GetCalculator("AB"); Assert.IsType <AlbertaTaxCalculator>(result); }
public OrderTotalsViewComponent( SmartDbContext db, ITaxService taxService, ITaxCalculator taxCalculator, ICurrencyService currencyService, IGiftCardService giftCardService, IShoppingCartService shoppingCartService, ILocalizationService localizationService, IOrderCalculationService orderCalculationService, ShoppingCartSettings shoppingCartSettings, MeasureSettings measureSettings, TaxSettings taxSettings) { _db = db; _taxService = taxService; _taxCalculator = taxCalculator; _currencyService = currencyService; _giftCardService = giftCardService; _shoppingCartService = shoppingCartService; _localizationService = localizationService; _orderCalculationService = orderCalculationService; _shoppingCartSettings = shoppingCartSettings; _measureSettings = measureSettings; _taxSettings = taxSettings; }
public void RegisterTaxCalculator(string identifier, ITaxCalculator taxCalculator) { if (!_taxCalculators.ContainsKey(identifier)) { _taxCalculators.Add(identifier, taxCalculator); } }
public ShoppingCart(ISalesPriceCalculator salesPriceCalculator, ITaxCalculator taxCalculator) { _salesPriceCalculator = salesPriceCalculator; _taxCalculator = taxCalculator; Products = new List <Product>(); }
public Cashier GetCashier(String strategy) { CalculatorFactory factory = new CalculatorFactory(); ITaxCalculator taxCal = factory.GetTaxCalculator(strategy); return(new Cashier(taxCal)); }
public OrderProcessor(IGetObjectService <Order> getOrderService, ITaxCalculator taxCalculator, IShippingCalculator shippingCalculator) { _getOrderService = getOrderService; _taxCalculator = taxCalculator; _shippingCalculator = shippingCalculator; }
public void TestSpaceshipTaxCalculatorCalculateMethodForCargoShip() { Spaceship cargoShip = new CargoShip(yearOfPurchase: 2332, milesTraveled: 344789); taxCalculator = new SpaceshipTax(cargoShip); Assert.AreEqual(expected: 326768.00, taxCalculator.Calculate(yearOfCalculation: 2369)); }
public CustomTaxCalculator(ITaxCalculator defaultTaxCalculator , IContentRepository contentRepository , ReferenceConverter referenceConverter) { this._defaultTaxCalculator = defaultTaxCalculator; this._contentRepository = contentRepository; this._referenceConverter = referenceConverter; }
public void T004_SelectTaxCalculatorAsBusinessLinear() { // When ITaxCalculator calculator = TaxCalculatorFactory.Create("linear business"); // Then Assert.IsTrue(calculator is LinearTaxCalculator); }
public void T003_SelectTaxCalculatorAsPersonal() { // When ITaxCalculator calculator = TaxCalculatorFactory.Create("personal first tax level"); // Then Assert.IsTrue(calculator is PersonalTaxCalculator); }
static void CalculateTax() { ITaxCalculator calculator = GetCalculator(); decimal salary = 20000M; decimal tax = calculator.CalculateTax(salary); Console.WriteLine(tax); }
public TaxWorkerListener(ITaxCalculator taxCalculator, INotificationService notificationService) { _subcribtion = Observable.FromEventPattern <EventHandler <double>, double>( h => taxCalculator.TaxesCalculated += h, h => taxCalculator.TaxesCalculated -= h) .Select(e => e.EventArgs) .Subscribe(taxInfo => notificationService.CreateNotification("New tax Info", $"Your Tax Return is:{taxInfo}")); }
public override Result DoWork() { ITaxCalculator taxCalculator = _app.Container.Resolve(typeof(ITaxCalculator)) as ITaxCalculator; double taxReturn = taxCalculator.CalculateTaxes(_instanceCount); Log($"Your Tax Return is: {taxReturn}"); return(Result.InvokeSuccess()); }
static void Main(string[] args) { Calculator clc = new Calculator(); ICalculator clc1 = clc; clc1.Add(); ITaxCalculator clcx = clc; }
void Initialize() { country = "Local"; TaxCalculatorFactory factory = new TaxCalculatorFactory(); taxCal = factory.GetTaxCalculator(country); biller = new Biller(taxCal); }
public TaxController(ILogger <TaxController> logger, ITaxCalculator taxCalculator, IExternalTaxComms externalTaxComms) { this._logger = logger; this._taxCalculator = taxCalculator; this._externalTaxComms = externalTaxComms; Console.Out.WriteLine("taxController created"); }
public void TestSpaceshipTaxCalculatorCalculateMethodForFamilyShip() { Spaceship familyShip = new FamilyShip(yearOfPurchase: 2300, milesTraveled: 2344); taxCalculator = new SpaceshipTax(familyShip); Assert.AreEqual(expected: 2715.00, actual: taxCalculator.Calculate(yearOfCalculation: 2307)); }
public virtual decimal GetPriceWithTax(ITaxCalculator calculator) { decimal price = 0; if (calculator != null) { price = calculator.GetTax(RawPrice) + RawPrice; } return price; }
public PricePresenter(IScanner scanner, IPriceDisplay priceDisplay, IProductRepository productRepository, ITaxCalculator taxCalculator) { m_Scanner = scanner; m_ProductRepository = productRepository; m_TaxCalculator = taxCalculator; m_PriceDisplay = priceDisplay; m_Scanner.BarcodeScanned += Scanner_BarcodeScanned; }
public uint CalculateExemptionForRent( Employee employee, ITaxCalculator ic) { var taxExemption = ic.calculate( employee.Property.IsRented, employee.Property.Location, employee.AnnualBasicSalary, employee.Property.MonthlyRent, employee.AnnualHouseRentAllowance); return taxExemption; }
public ValuesController(ITaxCalculator taxCalculator) { _taxCalculator = taxCalculator; }
public OrderProcessor(ITaxCalculator taxCalculator, IShippingCalculator shippingCalculator) { this.taxCalculator = taxCalculator; this.shippingCalculator = shippingCalculator; }
public SiteOrderFormCalculator(IShippingCalculator shippingCalculator, ILineItemCalculator lineItemCalculator, ITaxCalculator taxCalculator) : base(shippingCalculator, lineItemCalculator, taxCalculator) { _lineItemCalculator = lineItemCalculator; }
public Sale3(ITaxCalculator taxCalculator) { this.taxCalculator = taxCalculator; }
public frmTaxPayable() { InitializeComponent(); _iTaxCalculator = new TaxController(); }
public ProductService(IProductRepository productRepository, ITaxCalculator calculater) { _calculate = calculater; _productRespository = productRepository; }
public ShoppingBasket(ITaxCalculator taxCalculator, IReceiptBuilder receiptBuilder) { _taxCalculator = taxCalculator; _receiptBuilder = receiptBuilder; _itemsAddedToBasket = new List<Item>(); }
public SiteOrderGroupCalculator(IOrderFormCalculator orderFormCalculator, IShippingCalculator shippingCalculator, ITaxCalculator taxCalculator) : base(orderFormCalculator, shippingCalculator, taxCalculator) { _shippingCalculator = shippingCalculator; _taxCalculator = taxCalculator; }