public void EndWithProperties()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change = new Date(2019, 12, 31);

            properties.Change(change, new EffectivePropertyTestClass("Change1"));

            var end = new Date(2020, 01, 15);

            properties.End(end);

            properties.Values.Should().SatisfyRespectively(
                first =>
            {
                first.EffectivePeriod.Should().Be(new DateRange(change, end));
                first.Properties.Value.Should().Be("Change1");
            },
                second =>
            {
                second.EffectivePeriod.Should().Be(new DateRange(start, change.AddDays(-1)));
                second.Properties.Value.Should().Be("InitialValue");
            }
                );
        }
        public void ChangeOnSameDateAsExistingProperty()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change = new Date(2019, 12, 31);

            properties.Change(change, new EffectivePropertyTestClass("Change1"));

            properties.Change(change, new EffectivePropertyTestClass("Change2"));

            properties.Values.Should().SatisfyRespectively(
                first =>
            {
                first.EffectivePeriod.Should().Be(new DateRange(change, Date.MaxValue));
                first.Properties.Value.Should().Be("Change2");
            },
                second =>
            {
                second.EffectivePeriod.Should().Be(new DateRange(start, change.AddDays(-1)));
                second.Properties.Value.Should().Be("InitialValue");
            }
                );
        }
        public void PropertyAtDate(Date date, string result, bool exception)
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change1 = new Date(2019, 12, 15);

            properties.Change(change1, new EffectivePropertyTestClass("Change1"));

            var change2 = new Date(2019, 12, 31);

            properties.Change(change2, new EffectivePropertyTestClass("Change2"));

            var end = new Date(2020, 01, 17);

            properties.End(end);

            if (!exception)
            {
                properties[date].Value.Should().Be(result);
            }
            else
            {
                Action a = () => { var x = properties[date]; };
                a.Should().Throw <KeyNotFoundException>();
            }
        }
        public void EndWithNoExistingProperties()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var    end = new Date(2019, 11, 15);
            Action a   = () => properties.End(end);

            a.Should().Throw <EffectiveDateException>();
        }
        public void ChangeWithNoExistingProperties()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            properties.Values.Should().SatisfyRespectively(
                first =>
            {
                first.EffectivePeriod.Should().Be(new DateRange(start, Date.MaxValue));
                first.Properties.Value.Should().Be("InitialValue");
            }
                );
        }
        public void ChangeOutsideOfEffectivePeriod()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change1 = new Date(2019, 12, 31);

            properties.Change(change1, new EffectivePropertyTestClass("Change1"));

            var    change2 = new Date(2019, 11, 15);
            Action a       = () => properties.Change(change2, new EffectivePropertyTestClass("Change2"));

            a.Should().Throw <EffectiveDateException>();
        }
        public void EndOnStartDate()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            properties.End(start);

            properties.Values.Should().SatisfyRespectively(
                first =>
            {
                first.EffectivePeriod.Should().Be(new DateRange(start, start));
                first.Properties.Value.Should().Be("InitialValue");
            }
                );
        }
        public void EndInNonCurrentPeriod()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change1 = new Date(2019, 12, 15);

            properties.Change(change1, new EffectivePropertyTestClass("Change1"));

            var change2 = new Date(2019, 12, 31);

            properties.Change(change2, new EffectivePropertyTestClass("Change2"));

            var    end = new Date(2019, 12, 17);
            Action a   = () => properties.End(end);

            a.Should().Throw <EffectiveDateException>();
        }
        public void MatchesWithDateRange(DateRange dateRange, string value, bool result)
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change1 = new Date(2019, 12, 15);

            properties.Change(change1, new EffectivePropertyTestClass("Change1"));

            var change2 = new Date(2019, 12, 31);

            properties.Change(change2, new EffectivePropertyTestClass("Change2"));

            var end = new Date(2020, 01, 17);

            properties.End(end);

            properties.Matches(dateRange, x => x.Value == value).Should().Be(result);
        }
        public void ClosestToDate(Date date, string result)
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change1 = new Date(2019, 12, 15);

            properties.Change(change1, new EffectivePropertyTestClass("Change1"));

            var change2 = new Date(2019, 12, 31);

            properties.Change(change2, new EffectivePropertyTestClass("Change2"));

            var end = new Date(2020, 01, 17);

            properties.End(end);

            properties.ClosestTo(date).Value.Should().Be(result);
        }
        public void Value()
        {
            var properties = new EffectiveProperties <EffectivePropertyTestClass>();

            var start = new Date(2019, 12, 01);

            properties.Change(start, new EffectivePropertyTestClass("InitialValue"));

            var change1 = new Date(2019, 12, 15);

            properties.Change(change1, new EffectivePropertyTestClass("Change1"));

            var change2 = new Date(2019, 12, 31);

            properties.Change(change2, new EffectivePropertyTestClass("Change2"));

            var end = new Date(2020, 01, 17);

            properties.End(end);

            properties.Value(new Date(2019, 12, 17)).EffectivePeriod.Should().Be(new DateRange(new Date(2019, 12, 15), new Date(2019, 12, 30)));
        }