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

            timeSeriesData.AddRange(new[]
            {
                new AnnualDecimal(10, 99),
                new AnnualDecimal(13, 99),
                new AnnualDecimal(15, 99)
            });
            timeSeriesData.FillInGapsWith(year => new AnnualDecimal(year, 55));

            var enumerator = timeSeriesData.GetEnumerator();

            enumerator.Reset();
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(10, 99)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(11, 55)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(12, 55)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(13, 99)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(14, 55)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(15, 99)));
        }
Exemple #2
0
        public void ListWithNoGapWillRemainTheSame()
        {
            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.FillInGapsWith(year => new AnnualDecimal(year, 55));

            var enumerator = timeSeriesData.GetEnumerator();

            enumerator.Reset();
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(10, 10)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(11, 11)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(12, 12)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(13, 13)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(14, 14)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(15, 15)));
        }
Exemple #3
0
        public void DataIsSortedAfterAddingOneByOne()
        {
            var timeSeriesData = new TimeSeriesData <AnnualDecimal>();

            timeSeriesData.Add(new AnnualDecimal(30, 3));
            timeSeriesData.Add(new AnnualDecimal(10, 1));
            timeSeriesData.Add(new AnnualDecimal(40, 4));
            timeSeriesData.Add(new AnnualDecimal(20, 2));

            var enumerator = timeSeriesData.GetEnumerator();

            enumerator.Reset();
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(10, 1)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(20, 2)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(30, 3)));
            enumerator.MoveNext();
            Assert.That(enumerator.Current, Is.EqualTo(new AnnualDecimal(40, 4)));
        }