public void AddTaxEventCallsITaxesServiceAddAndReassignsToGridWithExtraRow()
        {
            _mockTaxesView.ShowTaxes += null;
            LastCall.IgnoreArguments();
            _mockTaxesView.AddTax += null;
            var addTaxEventRaiser = LastCall.IgnoreArguments().GetEventRaiser();
            const string taxType = "pstTax";
            DateTime? startDate = DateTime.Today;
            DateTime? endDate = DateTime.Today.AddYears(1);
            const JurisdictionEnum jurisdiction = JurisdictionEnum.ProvinceState;
            const int percent = 5;
            Expect.Call(_mockTaxesView.TaxType).Return(taxType);
            Expect.Call(_mockTaxesView.StartDate).Return(startDate);
            Expect.Call(_mockTaxesView.EndDate).Return(endDate);
            Expect.Call(_mockTaxesView.Jurisdiction).Return(jurisdiction);
            Expect.Call(_mockTaxesView.Percent).Return(percent);
            var tax = new Tax(taxType, startDate, endDate, jurisdiction, percent);
            _mockTaxesService.AddTax(tax);
            var taxes = new List<Tax> { tax };
            Expect.Call(_mockTaxesService.Taxes).Return(taxes);
            _mockTaxesView.TaxesDisplay = taxes;

            _mockRepository.ReplayAll();

            var taxesPresenter = new TaxesPresenter(_mockTaxesService, _mockTaxesView);
            addTaxEventRaiser.Raise(_mockTaxesView, EventArgs.Empty);
        }
        public void TaxesServiceCanAccumulateTaxes()
        {
            var taxesService = new TaxesService();
            var pstTax = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City);
            taxesService.AddTax(pstTax);

            Assert.IsTrue(taxesService.Taxes.Contains(pstTax));
        }
 public void TaxesServiceRejectsDuplicateTaxes()
 {
     var taxesService = new TaxesService();
     var pstTax1 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City);
     var pstTax2 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City);
     taxesService.AddTax(pstTax1);
     taxesService.AddTax(pstTax2);
 }
 public void TaxesServiceRejectsOverlappingTaxesPerTaxType()
 {
     var taxesService = new TaxesService();
     var pstTax1 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City);
     var pstTax2 = new Tax("PST", DateTime.Today.AddMonths(6), DateTime.Today.AddYears(1), JurisdictionEnum.City);
     taxesService.AddTax(pstTax1);
     taxesService.AddTax(pstTax2);
 }
예제 #5
0
        public void CityCanAccumulateTaxes()
        {
            var city = new City("Winnipeg");
            var pstTax = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6));
            city.AddTax(pstTax);

            Assert.IsTrue(city.Taxes.Contains(pstTax));
        }
예제 #6
0
        public void AddTax(Tax tax)
        {
            if (tax == null) throw new ArgumentNullException("tax");
            RejectDuplicateTaxes(tax);
            RejectOverlappingTaxes(tax);

            this.Taxes.Add(tax);
        }
예제 #7
0
 public void CityRejectsDuplicateTaxes()
 {
     var city = new City("Winnipeg");
     var pstTax1 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6));
     var pstTax2 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6));
     city.AddTax(pstTax1);
     city.AddTax(pstTax2);
 }
예제 #8
0
 public void CityRejectsOverlappingTaxesPerTaxType()
 {
     var city = new City("Winnipeg");
     var pstTax1 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6));
     var pstTax2 = new Tax("PST", DateTime.Today.AddMonths(6), DateTime.Today.AddYears(1));
     city.AddTax(pstTax1);
     city.AddTax(pstTax2);
 }
예제 #9
0
        public void TaxesAreEqualWhenConstructorParametersMatch()
        {
            var tax1 = new Tax("PST", DateTime.Today.AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City);
            var tax2 = new Tax("PST", DateTime.Today.AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City);

            Assert.IsTrue(tax1.Equals(tax2));
            // Assert.AreSame(tax1, tax2) failed, may be referencing another nunit namespace??
        }
예제 #10
0
        public void CityDelegatesAddedTaxesToInjectedTaxesService()
        {
            // expectations
            var pstTax = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City);
            _mockTaxesService.AddTax(pstTax);

            _mockRepository.ReplayAll();

            var city = new City("Winnipeg", _mockTaxesService);
            city.AddTax(pstTax);
        }
        public void ProvinceStateDelegatesAddedTaxesToInjectedTaxesService()
        {
            // expectations
            var pstTax = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.ProvinceState);
            _mockTaxesService.AddTax(pstTax);

            _mockRepository.ReplayAll();

            var provinceState = new ProvinceState("MB", _mockTaxesService);
            provinceState.AddTax(pstTax);
        }
예제 #12
0
        public void CountryDelegatesAddedTaxesToInjectedTaxesService()
        {
            // expectations
            var pstTax = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.Country, 5);
            _mockTaxesService.AddTax(pstTax);

            _mockRepository.ReplayAll();

            var country = new Country("MB", _mockTaxesService);
            country.AddTax(pstTax);
        }
        public void TaxesServiceDistinguishesCorrectlyEachJurisdiction()
        {
            var taxesService = new TaxesService();

            var city = new City("CityTax", taxesService);
            var cityTax = new Tax("CityTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City);
            city.AddTax(cityTax);

            var provinceState = new City("ProvStateTax", taxesService);
            var provStateTax = new Tax("ProvStateTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.ProvinceState);
            provinceState.AddTax(provStateTax);

            var country = new City("CountryTax", taxesService);
            var countryTax = new Tax("CountryTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.Country);
            country.AddTax(countryTax);

            Assert.AreEqual(1, city.Taxes.Count);
            Assert.AreEqual(1, provinceState.Taxes.Count);
            Assert.AreEqual(1, country.Taxes.Count);
        }
예제 #14
0
 public void TaxCanBeCreatedWhenAllPropertiesSupplied()
 {
     var tax = new Tax("PST", DateTime.Today.AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City);
     Assert.IsNotNull(tax);
 }
예제 #15
0
 public void TaxCannotBeCreatedWithNullTaxType()
 {
     var tax = new Tax(null, DateTime.Today.AddDays(1), DateTime.Today.AddYears(1));
 }
예제 #16
0
 public void TaxCannotBeCreatedWithNullStartDate()
 {
     var tax = new Tax("PST", null, DateTime.Today.AddYears(1));
 }
예제 #17
0
 public void TaxStartDateCannotBeGreaterThanEndDate()
 {
     var tax = new Tax("PST", DateTime.Today.AddYears(1).AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City);
     Assert.IsNotNull(tax);
 }
예제 #18
0
 public void TaxCannotBeCreatedWithNullTaxType()
 {
     var tax = new Tax(null, DateTime.Today.AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City);
 }
예제 #19
0
 public void TaxCannotBeCreatedWithNullEndDate()
 {
     var tax = new Tax("PST", DateTime.Today.AddDays(1), null, JurisdictionEnum.City);
 }
 private static bool IsFutureTax(Tax tax, Tax currowTax)
 {
     return(currowTax.TaxType.Equals(tax.TaxType) &&
            tax.StartDate.Value > currowTax.StartDate);
 }
예제 #21
0
 private static bool IsEarlierTax(Tax tax, Tax currowTax)
 {
     return currowTax.TaxType.Equals(tax.TaxType)
            && tax.StartDate.Value < currowTax.StartDate;
 }
 private static bool CurrowTaxOverlapsEndDateOfPreviousTax(Tax tax, Tax currowTax)
 {
     return(currowTax.TaxType.Equals(tax.TaxType) &&
            currowTax.StartDate <= tax.EndDate);
 }
 public void AddTax(Tax tax)
 {
     _taxesService.AddTax(tax);
 }
예제 #24
0
 public void AddTax(Tax tax)
 {
     _taxesService.AddTax(tax);
 }
예제 #25
0
 private static bool IsFutureTax(Tax tax, Tax currowTax)
 {
     return currowTax.TaxType.Equals(tax.TaxType)
            && tax.StartDate.Value > currowTax.StartDate;
 }
예제 #26
0
 private void RejectDuplicateTaxes(Tax tax)
 {
     if (this.Taxes.Contains(tax))
         throw new DuplicateTaxesException();
 }
예제 #27
0
 public void TaxCannotBeCreatedWithAllNullProperties()
 {
     var tax = new Tax(null, null, null, JurisdictionEnum.Unspecified);
 }
예제 #28
0
 public void TaxCannotBeCreatedWithAnUnspecifiedJurisdiction()
 {
     var tax = new Tax("PST", DateTime.Today.AddDays(1), null, JurisdictionEnum.Unspecified);
 }
 private static bool FutureTaxOverlapsEndDateOfCurrowTax(Tax tax, Tax currowTax)
 {
     return(currowTax.TaxType.Equals(tax.TaxType) &&
            tax.StartDate <= currowTax.EndDate);
 }
예제 #30
0
 public void TaxCannotBeCreatedWithNullStartDate()
 {
     var tax = new Tax("PST", null, DateTime.Today.AddYears(1), JurisdictionEnum.City);
 }
예제 #31
0
        public void Setup()
        {
            _mockRepository = new MockRepository();
            _mockTaxesService = _mockRepository.Stub<ITaxesService>();

            _city = new City("CityTax", _mockTaxesService);
            var cityTax = new Tax("CityTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City, 2);
            _mockTaxesService.Taxes.Add(cityTax);

            _provinceState = new ProvinceState("ProvStateTax", _mockTaxesService);
            var provStateTax = new Tax("ProvStateTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.ProvinceState, 3);
            _mockTaxesService.Taxes.Add(provStateTax);

            _country = new Country("CountryTax", _mockTaxesService);
            var countryTax = new Tax("CountryTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.Country, 4);
            _mockTaxesService.Taxes.Add(countryTax);
        }
 private static bool IsEarlierTax(Tax tax, Tax currowTax)
 {
     return(currowTax.TaxType.Equals(tax.TaxType) &&
            tax.StartDate.Value < currowTax.StartDate);
 }
예제 #33
0
 public void TaxCannotBeCreatedWithAllNullProperties()
 {
     var tax = new Tax(null, null, null);
 }
예제 #34
0
 public void TaxCannotBeCreatedWithNullEndDate()
 {
     var tax = new Tax("PST", DateTime.Today.AddDays(1), null);
 }
예제 #35
0
        private void RejectOverlappingTaxes(Tax tax)
        {
            foreach (var currowTax in this.Taxes)
            {
                if (IsFutureTax(tax, currowTax)
                    && FutureTaxOverlapsEndDateOfCurrowTax(tax, currowTax))
                    throw new OverlappingTaxTypesException();

                if (IsEarlierTax(tax, currowTax)
                    && CurrowTaxOverlapsEndDateOfPreviousTax(tax, currowTax))
                    throw new OverlappingTaxTypesException();
            }
        }