Beispiel #1
0
        public void GettingNonExistentYearShouldReturnNull()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.AddRange(new[]
            {
                new AnnualDecimal(10, null),
                new AnnualDecimal(11, null),
                new AnnualDecimal(12, null),
            });
            Assert.That(timeSeriesData.GetYear(100), Is.Null);
            Assert.That(timeSeriesData.GetYear(10), Is.EqualTo(new AnnualDecimal(10, null)));
            Assert.That(timeSeriesData.GetYear(12), Is.EqualTo(new AnnualDecimal(12, null)));
        }
Beispiel #2
0
        public void CanCreateWithNonPopulatedYears()
        {
            var prepopulated = new List <AnnualDecimal>();

            prepopulated.Add(new AnnualDecimal(0, 1));
            prepopulated.Add(new AnnualDecimal(0, 2));
            prepopulated.Add(new AnnualDecimal(0, 3));
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>(prepopulated);

            Assert.That(timeSeriesData.Count, Is.EqualTo(3));
            Assert.That(timeSeriesData.GetYear(0), Is.EqualTo(new AnnualDecimal(0, 1)));
            Assert.That(timeSeriesData.GetYear(1), Is.EqualTo(new AnnualDecimal(1, 2)));
            Assert.That(timeSeriesData.GetYear(2), Is.EqualTo(new AnnualDecimal(2, 3)));
        }
Beispiel #3
0
        public void SettingAndGettingData()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.Add(new AnnualDecimal(10, 100));
            Assert.That(timeSeriesData.Count, Is.EqualTo(1));
            Assert.That(timeSeriesData.GetYear(10).Value, Is.EqualTo(100));
        }
Beispiel #4
0
        public void GettingAbsentValue()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.Add(new AnnualDecimal(5, 5));
            timeSeriesData.Add(new AnnualDecimal(20, 20));
            Assert.That(timeSeriesData.GetYear(10), Is.Null);
        }
Beispiel #5
0
        public void RewritingTheSameYearOnAnSingleElementList()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.Add(new AnnualDecimal(10, 100));
            timeSeriesData.Add(new AnnualDecimal(10, 200));
            Assert.That(timeSeriesData.Count, Is.EqualTo(1));
            Assert.That(timeSeriesData.GetYear(10).Value, Is.EqualTo(200));
        }
Beispiel #6
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)));
        }
Beispiel #7
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)));
        }
Beispiel #8
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)));
        }
Beispiel #9
0
        public void RewritingTheSameYearOnPopulatedList()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.Add(new AnnualDecimal(1, 100));
            timeSeriesData.Add(new AnnualDecimal(2, 100));
            timeSeriesData.Add(new AnnualDecimal(10, 100));
            timeSeriesData.Add(new AnnualDecimal(10, 200));
            Assert.That(timeSeriesData.Count, Is.EqualTo(3));
            Assert.That(timeSeriesData.GetYear(10).Value, Is.EqualTo(200));
        }
Beispiel #10
0
        public void GettingItemFromAnEmptyArray()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            Assert.That(timeSeriesData.GetYear(10), Is.Null);
        }