Ejemplo n.º 1
0
        public void StartAndEndYearShouldFailWhenTimeSeriesEmpty()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            Assert.That(timeSeriesData.IsNotEmpty(), Is.False);
            Assert.Throws <InvalidOperationException>(() => timeSeriesData.StartYear());
            Assert.Throws <InvalidOperationException>(() => timeSeriesData.EndYear());
            Assert.Throws <InvalidOperationException>(() => timeSeriesData.StartYearOfNonZeroValue());
            Assert.Throws <InvalidOperationException>(() => timeSeriesData.EndYearOfNonZeroValue());
        }
Ejemplo n.º 2
0
        public void HasZeroValues()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.Add(new AnnualDecimal(10, 0));
            timeSeriesData.Add(new AnnualDecimal(20, 0));
            Assert.That(timeSeriesData.HasNonNullValues(), Is.True);
            Assert.That(timeSeriesData.HasNonZeroValues(), Is.False);
            Assert.That(timeSeriesData.StartYear(), Is.EqualTo(10));
            Assert.That(timeSeriesData.EndYear(), Is.EqualTo(20));
        }
Ejemplo n.º 3
0
        public void StartAndEndYearShouldFailWhenTimeSeriesIsAllZero()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.Add(new AnnualDecimal(10, 0));
            timeSeriesData.Add(new AnnualDecimal(20, 0));
            Assert.That(timeSeriesData.IsNotEmpty(), Is.True);
            Assert.That(timeSeriesData.StartYear(), Is.EqualTo(10));
            Assert.That(timeSeriesData.EndYear(), Is.EqualTo(20));
            Assert.Throws <InvalidOperationException>(() => timeSeriesData.StartYearOfNonZeroValue());
            Assert.Throws <InvalidOperationException>(() => timeSeriesData.EndYearOfNonZeroValue());
        }
Ejemplo n.º 4
0
        public void ShouldOnlyTrimTheStart()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.AddRange(new[]
            {
                new AnnualDecimal(10, null),
                new AnnualDecimal(11, null),
                new AnnualDecimal(12, 12),
                new AnnualDecimal(13, 13),
                new AnnualDecimal(14, null),
                new AnnualDecimal(15, null)
            });
            timeSeriesData.TrimNullDataFromTheStart();
            Assert.That(timeSeriesData.Count, Is.EqualTo(4));
            Assert.That(timeSeriesData.GetYear(timeSeriesData.StartYear()), Is.EqualTo(new AnnualDecimal(12, 12)));
            Assert.That(timeSeriesData.GetYear(timeSeriesData.EndYear()), Is.EqualTo(new AnnualDecimal(15, null)));
        }
Ejemplo n.º 5
0
        public void ShouldNotRemoveNullValuesFromTheMiddle()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.AddRange(new[]
            {
                new AnnualDecimal(10, 10),
                new AnnualDecimal(11, null),
                new AnnualDecimal(12, null),
                new AnnualDecimal(13, null),
                new AnnualDecimal(14, null),
                new AnnualDecimal(15, 15)
            });
            timeSeriesData.TrimNullData();
            Assert.That(timeSeriesData.Count, Is.EqualTo(6));
            Assert.That(timeSeriesData.GetYear(timeSeriesData.StartYear()), Is.EqualTo(new AnnualDecimal(10, 10)));
            Assert.That(timeSeriesData.GetYear(timeSeriesData.EndYear()), Is.EqualTo(new AnnualDecimal(15, 15)));
        }
Ejemplo n.º 6
0
        public void TrimmedNonNullDataWillReturnTheSameTimeSeries()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.AddRange(new[]
            {
                new AnnualDecimal(10, 10),
                new AnnualDecimal(11, 11),
                new AnnualDecimal(12, 12),
                new AnnualDecimal(13, 13),
                new AnnualDecimal(14, 14),
                new AnnualDecimal(15, 15)
            });
            timeSeriesData.TrimNullData();
            Assert.That(timeSeriesData.Count, Is.EqualTo(6));
            Assert.That(timeSeriesData.GetYear(timeSeriesData.StartYear()), Is.EqualTo(new AnnualDecimal(10, 10)));
            Assert.That(timeSeriesData.GetYear(timeSeriesData.EndYear()), Is.EqualTo(new AnnualDecimal(15, 15)));
        }