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); }
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)); }
public void AddTax(Tax tax) { if (tax == null) throw new ArgumentNullException("tax"); RejectDuplicateTaxes(tax); RejectOverlappingTaxes(tax); this.Taxes.Add(tax); }
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); }
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); }
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?? }
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); }
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); }
public void TaxCanBeCreatedWhenAllPropertiesSupplied() { var tax = new Tax("PST", DateTime.Today.AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City); Assert.IsNotNull(tax); }
public void TaxCannotBeCreatedWithNullTaxType() { var tax = new Tax(null, DateTime.Today.AddDays(1), DateTime.Today.AddYears(1)); }
public void TaxCannotBeCreatedWithNullStartDate() { var tax = new Tax("PST", null, DateTime.Today.AddYears(1)); }
public void TaxStartDateCannotBeGreaterThanEndDate() { var tax = new Tax("PST", DateTime.Today.AddYears(1).AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City); Assert.IsNotNull(tax); }
public void TaxCannotBeCreatedWithNullTaxType() { var tax = new Tax(null, DateTime.Today.AddDays(1), DateTime.Today.AddYears(1), JurisdictionEnum.City); }
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); }
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); }
private static bool IsFutureTax(Tax tax, Tax currowTax) { return currowTax.TaxType.Equals(tax.TaxType) && tax.StartDate.Value > currowTax.StartDate; }
private void RejectDuplicateTaxes(Tax tax) { if (this.Taxes.Contains(tax)) throw new DuplicateTaxesException(); }
public void TaxCannotBeCreatedWithAllNullProperties() { var tax = new Tax(null, null, null, JurisdictionEnum.Unspecified); }
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); }
public void TaxCannotBeCreatedWithNullStartDate() { var tax = new Tax("PST", null, DateTime.Today.AddYears(1), JurisdictionEnum.City); }
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); }
public void TaxCannotBeCreatedWithAllNullProperties() { var tax = new Tax(null, null, null); }
public void TaxCannotBeCreatedWithNullEndDate() { var tax = new Tax("PST", DateTime.Today.AddDays(1), null); }
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(); } }