예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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;
 }
예제 #5
0
        public void InitializeTest()
        {
            var mapper        = new AutoMapperSetup().CreateAutoMapperConfig();
            var configuration = new ConfigurationSetup().CreateConfiguration();

            taxCalculator = new TaxCalculatorTaxJarApi(configuration, mapper);
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
 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;
        }
예제 #10
0
 public TaxCalculatorService(IEmployeeRepository employeeRepository, ITaxCalculator calculator, IPayslipGenerator generator, ILogger logger)
 {
     Repository = employeeRepository;
     Calculator = calculator;
     Generator  = generator;
     Logger     = logger;
 }
예제 #11
0
        public void CreateAlbertaTaxCalculator()
        {
            var            taxCalculatorFactory = new TaxCalculatorFactory();
            ITaxCalculator result = taxCalculatorFactory.GetTaxCalculator("AB");

            Assert.IsType <AlbertaTaxCalculator>(result);
        }
예제 #12
0
        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();
        }
예제 #13
0
        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));
        }
예제 #14
0
        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;
 }
예제 #16
0
 public void RegisterTaxCalculator(string identifier, ITaxCalculator taxCalculator)
 {
     if (!_taxCalculators.ContainsKey(identifier))
     {
         _taxCalculators.Add(identifier, taxCalculator);
     }
 }
예제 #17
0
        public ShoppingCart(ISalesPriceCalculator salesPriceCalculator, ITaxCalculator taxCalculator)
        {
            _salesPriceCalculator = salesPriceCalculator;
            _taxCalculator        = taxCalculator;

            Products = new List <Product>();
        }
예제 #18
0
        public Cashier GetCashier(String strategy)
        {
            CalculatorFactory factory = new CalculatorFactory();
            ITaxCalculator    taxCal  = factory.GetTaxCalculator(strategy);

            return(new Cashier(taxCal));
        }
예제 #19
0
 public OrderProcessor(IGetObjectService <Order> getOrderService,
                       ITaxCalculator taxCalculator, IShippingCalculator shippingCalculator)
 {
     _getOrderService    = getOrderService;
     _taxCalculator      = taxCalculator;
     _shippingCalculator = shippingCalculator;
 }
예제 #20
0
        public void TestSpaceshipTaxCalculatorCalculateMethodForCargoShip()
        {
            Spaceship cargoShip = new CargoShip(yearOfPurchase: 2332, milesTraveled: 344789);

            taxCalculator = new SpaceshipTax(cargoShip);
            Assert.AreEqual(expected: 326768.00, taxCalculator.Calculate(yearOfCalculation: 2369));
        }
예제 #21
0
 public CustomTaxCalculator(ITaxCalculator defaultTaxCalculator
                            , IContentRepository contentRepository
                            , ReferenceConverter referenceConverter)
 {
     this._defaultTaxCalculator = defaultTaxCalculator;
     this._contentRepository    = contentRepository;
     this._referenceConverter   = referenceConverter;
 }
예제 #22
0
        public void T004_SelectTaxCalculatorAsBusinessLinear()
        {
            // When
            ITaxCalculator calculator = TaxCalculatorFactory.Create("linear business");

            // Then
            Assert.IsTrue(calculator is LinearTaxCalculator);
        }
예제 #23
0
        public void T003_SelectTaxCalculatorAsPersonal()
        {
            // When
            ITaxCalculator calculator = TaxCalculatorFactory.Create("personal first tax level");

            // Then
            Assert.IsTrue(calculator is PersonalTaxCalculator);
        }
예제 #24
0
        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}"));
 }
예제 #26
0
        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());
        }
예제 #27
0
        static void Main(string[] args)
        {
            Calculator  clc  = new Calculator();
            ICalculator clc1 = clc;

            clc1.Add();
            ITaxCalculator clcx = clc;
        }
예제 #28
0
        void Initialize()
        {
            country = "Local";
            TaxCalculatorFactory factory = new TaxCalculatorFactory();

            taxCal = factory.GetTaxCalculator(country);
            biller = new Biller(taxCal);
        }
예제 #29
0
        public TaxController(ILogger <TaxController> logger, ITaxCalculator taxCalculator, IExternalTaxComms externalTaxComms)
        {
            this._logger           = logger;
            this._taxCalculator    = taxCalculator;
            this._externalTaxComms = externalTaxComms;

            Console.Out.WriteLine("taxController created");
        }
예제 #30
0
        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));
        }
예제 #31
0
 public virtual decimal GetPriceWithTax(ITaxCalculator calculator)
 {
     decimal price = 0;
     if (calculator != null)
     {
      price = calculator.GetTax(RawPrice) + RawPrice;
     }
     return price;
 }
예제 #32
0
        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;
 }
예제 #35
0
 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;
 }
예제 #37
0
파일: Sale3.cs 프로젝트: Raj2157/Ninject
 public Sale3(ITaxCalculator taxCalculator)
 {
     this.taxCalculator = taxCalculator;
 }
예제 #38
0
 public frmTaxPayable()
 {
     InitializeComponent();
     _iTaxCalculator = new TaxController();
 }
예제 #39
0
 public ProductService(IProductRepository productRepository, ITaxCalculator calculater)
 {
     _calculate = calculater;
     _productRespository = productRepository;
 }
예제 #40
0
 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;
 }