Exemplo n.º 1
0
        public void Given_RegisterTaxCalculator_When_Id_Does_Exist_ShouldNot_AddTaxCalculator()
        {
            //------------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--------------------------------
            taxResolver.RegisterTaxCalculator(identifier, taxCalculator);
            //------------Assert--------------------------------
            var numberOfTaxResolvers = taxResolver.Count();

            Assert.AreEqual(5, numberOfTaxResolvers);
        }
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);
            }
        }