Esempio n. 1
0
        public static ITaxCalcService CreateCalcService(double taxRate, double importDutyRate, IEnumerable <string> taxExemptProductTypeNames)
        {
            var exemptDiscriminatorService = new TaxExemptDiscriminatorService(taxExemptProductTypeNames);
            var taxCalcService             = new TaxCalcService(taxRate, importDutyRate, exemptDiscriminatorService);

            return(taxCalcService);
        }
Esempio n. 2
0
        public void IsTaxExempt_ReturnsValueBasedOnDefinedTypeNames_Test(ProductType prodType, bool expected)
        {
            var iProduct        = Mock.Create <IProduct>();
            var productTypeName = prodType.ToString();

            Mock.Arrange(() => iProduct.ProdType).Returns(productTypeName);

            var sut = new TaxExemptDiscriminatorService(Settings.Config.TaxExemptProductTypeNames);

            var actual = sut.IsTaxExempt(iProduct);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void IsTaxExempt_ReturnsTrue_WhenTypeNameIncludedInConstructor_Test()
        {
            var iProduct        = Mock.Create <IProduct>();
            var productTypeName = "book";

            Mock.Arrange(() => iProduct.ProdType).Returns(productTypeName);
            IEnumerable <string> productTypeNames = new List <string>
            {
                productTypeName
            };

            var sut = new TaxExemptDiscriminatorService(productTypeNames);

            var actual = sut.IsTaxExempt(iProduct);

            Assert.That(actual, Is.True);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var exemptDiscriminatorService = new TaxExemptDiscriminatorService(Settings.Config.TaxExemptProductTypeNames);
            var taxCalcService             = new TaxCalcService(Settings.Config.TaxRate, Settings.Config.ImportDutyRate, exemptDiscriminatorService);
            var salesTransaction           = new SalesTransaction(taxCalcService);

            Console.WriteLine("Problem: Sales Taxes");
            Console.WriteLine();

            var input = GetInput1Items1();

            WriteReceiptToConsole(input, salesTransaction, 1);

            input = GetInput1Items2();
            WriteReceiptToConsole(input, salesTransaction, 2);

            input = GetInput1Items3();
            WriteReceiptToConsole(input, salesTransaction, 3);
        }