public void TaxAmountChecks()
        {
            var validator = new TaxScheduleValidator();

            var schedule = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 03), frequency: ScheduleFrequency.Daily);
            var tax      = new MunicipalityTaxDetails()
            {
                MunicipalitySchedule = schedule, TaxAmount = 0.1
            };
            var status = validator.ValidateTaxDetails(tax);

            Assert.AreEqual(TaxScheduleValidationResult.Valid, status);

            tax.TaxAmount = 0;
            status        = validator.ValidateTaxDetails(tax);
            Assert.AreEqual(TaxScheduleValidationResult.Valid, status);

            tax.TaxAmount = -0.1;
            status        = validator.ValidateTaxDetails(tax);
            Assert.AreEqual(TaxScheduleValidationResult.TaxAmountInvalid, status);

            schedule = new MunicipalityTaxSchedule(municipality: null, begin: new DateTime(2017, 06, 03), frequency: ScheduleFrequency.Daily);
            tax      = new MunicipalityTaxDetails()
            {
                MunicipalitySchedule = schedule, TaxAmount = 0.1
            };
            status = validator.ValidateTaxDetails(tax);
            Assert.AreEqual(TaxScheduleValidationResult.MunicipalityInvalid, status);
        }
        public void TestApplicable()
        {
            var schedule = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Daily, begin: new DateTime(2017, 06, 02));

            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(1)));

            schedule = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Weekly, begin: new DateTime(2017, 06, 05));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(-1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(2)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(3)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(4)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(5)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(6)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(7)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(1)));

            schedule = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Monthly, begin: new DateTime(2017, 06, 01));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(-1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(1).AddDays(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(1)));

            schedule = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Yearly, begin: new DateTime(2017, 01, 01));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(-1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddDays(1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddMonths(1).AddDays(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(-1)));
            Assert.IsFalse(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(1)));
            Assert.IsTrue(schedule.IsApplicable(schedule.ScheduleBeginDate.AddYears(1).AddDays(-1)));
        }
        public void NoMunicipality()
        {
            var validator = new TaxScheduleValidator();

            var tax    = new MunicipalityTaxSchedule(municipality: "", begin: new DateTime(2017, 06, 03), frequency: ScheduleFrequency.Daily);
            var status = validator.ValidateTaxSchedule(tax);

            Assert.AreEqual(TaxScheduleValidationResult.MunicipalityInvalid, status);

            tax    = new MunicipalityTaxSchedule(municipality: "   ", begin: new DateTime(2017, 06, 03), frequency: ScheduleFrequency.Daily);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.MunicipalityInvalid, status);

            tax    = new MunicipalityTaxSchedule(municipality: null, begin: new DateTime(2017, 06, 03), frequency: ScheduleFrequency.Daily);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.MunicipalityInvalid, status);
        }
        public void TestMostApplicable()
        {
            var daily   = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Daily, begin: new DateTime(2017, 06, 05));
            var weekly  = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Weekly, begin: new DateTime(2017, 06, 05));
            var monthly = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Monthly, begin: new DateTime(2017, 06, 01));
            var yearly  = new MunicipalityTaxSchedule(municipality: "Kaunas", frequency: ScheduleFrequency.Yearly, begin: new DateTime(2017, 01, 01));

            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { yearly, monthly, weekly, daily }, new DateTime(2017, 06, 05)), daily);
            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { daily, weekly, monthly, yearly }, new DateTime(2017, 06, 05)), daily);

            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { yearly, monthly, weekly, daily }, new DateTime(2017, 06, 06)), weekly);
            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { monthly, weekly, daily, yearly }, new DateTime(2017, 06, 06)), weekly);

            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { yearly, monthly, weekly, daily }, new DateTime(2017, 06, 01)), monthly);
            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { monthly, yearly, daily, weekly }, new DateTime(2017, 06, 01)), monthly);

            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { yearly, monthly, weekly, daily }, new DateTime(2017, 04, 05)), yearly);
            Assert.AreEqual(MunicipalityTaxSchedule.MostApplicable(new[] { weekly, daily, yearly, monthly }, new DateTime(2017, 04, 05)), yearly);
        }
        public void ScheduleDateCheck()
        {
            var validator = new TaxScheduleValidator();

            #region Daily
            var tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 03), frequency: ScheduleFrequency.Daily);
            var status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.Valid, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 01), frequency: ScheduleFrequency.Daily);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.Valid, status);
            #endregion

            #region Weekly
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 05), frequency: ScheduleFrequency.Weekly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.Valid, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 06), frequency: ScheduleFrequency.Weekly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 04), frequency: ScheduleFrequency.Weekly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            #endregion

            #region Monthly
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 01), frequency: ScheduleFrequency.Monthly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.Valid, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 06), frequency: ScheduleFrequency.Monthly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 06, 05), frequency: ScheduleFrequency.Monthly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            #endregion

            #region Yearly
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 01, 01), frequency: ScheduleFrequency.Yearly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.Valid, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 02, 01), frequency: ScheduleFrequency.Yearly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 01, 02), frequency: ScheduleFrequency.Yearly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 12, 31), frequency: ScheduleFrequency.Yearly);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            #endregion

            #region Time
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 03, 04, 5, 6, 7), frequency: ScheduleFrequency.Daily);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            tax    = new MunicipalityTaxSchedule(municipality: "Test", begin: new DateTime(2017, 03, 04, 12, 0, 0), frequency: ScheduleFrequency.Daily);
            status = validator.ValidateTaxSchedule(tax);
            Assert.AreEqual(TaxScheduleValidationResult.DateUnsuitableForSchedule, status);
            #endregion
        }