Exemplo n.º 1
0
        public void Given_PostalCodeTaxResolver_Should_StartWith_4TaxCalculators()
        {
            //-------------------Setup---------------------------------------
            //--------------------Execute------------------------------------
            var postalTaxResolver = new PostalCodeTaxResolver(new Mock <IIncomeValidator>().Object);

            //--------------------Assert-------------------------------------
            Assert.AreEqual(4, postalTaxResolver.Count());
            Assert.IsInstanceOf <ProgressiveTaxCalculator>(postalTaxResolver.GetTaxCalculator("7441"));
            Assert.IsInstanceOf <FlatValueTaxCalculator>(postalTaxResolver.GetTaxCalculator("A100"));
            Assert.IsInstanceOf <FlatRateTaxCalculator>(postalTaxResolver.GetTaxCalculator("7000"));
            Assert.IsInstanceOf <ProgressiveTaxCalculator>(postalTaxResolver.GetTaxCalculator("1000"));
        }
Exemplo n.º 2
0
        public void Given_GetTaxCalculator_When_Id_Does_Exist_Should_ReturnTaxCalculator()
        {
            //------------Setup---------------------------------
            var          taxCalculator = new FlatRateTaxCalculator(new Mock <IIncomeValidator>().Object);
            const string identifier    = "Flat Rate";
            var          taxResolver   = new PostalCodeTaxResolver(new Mock <IIncomeValidator>().Object);

            taxResolver.RegisterTaxCalculator(identifier, taxCalculator);
            //------------Execute--------------------------------
            var returnedTaxCalculator = taxResolver.GetTaxCalculator(identifier);

            //------------Assert--------------------------------
            Assert.AreEqual(taxCalculator, returnedTaxCalculator);
        }
Exemplo n.º 3
0
        public void Given_GetTaxCalculator_When_Id_DoesNot_Exist_Should_ThrowException()
        {
            //------------Setup---------------------------------
            var          taxCalculator = new FlatRateTaxCalculator(new Mock <IIncomeValidator>().Object);
            const string identifier    = "Flat Rate";
            var          taxResolver   = new PostalCodeTaxResolver(new Mock <IIncomeValidator>().Object);

            taxResolver.RegisterTaxCalculator(identifier, taxCalculator);
            //------------Execute--------------------------------
            try
            {
                taxResolver.GetTaxCalculator("SomeRandomTaxCalculator");
            }
            catch (System.Exception e)
            {
                //------------Assert--------------------------------
                Assert.AreEqual("No Tax Calculator found", e.Message);
            }
        }