Esempio n. 1
0
        public void GetSeries()
        {
            var stock = new Stock {
                Isin = "DE0005190003"
            };

            stock.Company = new Company {
                Name = "BMW"
            };
            stock.Company.Stocks.Add(stock);

            var dataProvider = new WebFigureProvider(new StorageService(myProjectHost.Object), myLutService.Object);

            dataProvider.CustomResolverCreator = r => new CompositeMacroResolver(new MacroResolver(TestDataRoot), r);

            var request = new DataProviderRequest(stock, typeof(Dividend), new YearPeriod(2001), new YearPeriod(2004))
            {
                WithPreview  = false,
                ThrowOnError = true
            };

            var series = new List <IFigure>();

            dataProvider.Fetch(request, series);

            Assert.That(series.Count, Is.EqualTo(4));

            foreach (var dividend in series.Cast <Dividend>())
            {
                Assert.That(dividend.Company.Stocks.First().Isin, Is.EqualTo("DE0005190003"));
                Assert.That(dividend.Period, Is.InstanceOf <YearPeriod>());
                Assert.That(dividend.Source, Does.Contain("ariva").IgnoreCase.And.Contains("fundamentals").IgnoreCase);
                Assert.That(dividend.Timestamp.Date, Is.EqualTo(DateTime.Today));
                Assert.That(dividend.Currency, Is.Null);
            }

            Assert.That(series[0].Period, Is.EqualTo(new YearPeriod(2001)));
            Assert.That(series[0].Value, Is.EqualTo(350000000d));
            Assert.That(series[1].Period, Is.EqualTo(new YearPeriod(2002)));
            Assert.That(series[1].Value, Is.EqualTo(351000000d));
            Assert.That(series[2].Period, Is.EqualTo(new YearPeriod(2003)));
            Assert.That(series[2].Value, Is.EqualTo(392000000d));
            Assert.That(series[3].Period, Is.EqualTo(new YearPeriod(2004)));
            Assert.That(series[3].Value, Is.EqualTo(419000000d));
        }
Esempio n. 2
0
        public void GetCell()
        {
            var stock = new Stock {
                Isin = "DE0007664039"
            };

            stock.Company = new Company {
                Name = "Volkswagen"
            };
            stock.Company.Stocks.Add(stock);

            var dataProvider = new WebFigureProvider(new StorageService(myProjectHost.Object), myLutService.Object);

            dataProvider.CustomResolverCreator = r => new CompositeMacroResolver(new MacroResolver(TestDataRoot), r);

            var request = new DataProviderRequest(stock, typeof(Price), new DayPeriod(DateTime.MinValue), new DayPeriod(DateTime.MaxValue))
            {
                WithPreview  = false,
                ThrowOnError = true
            };

            var series = new List <IFigure>();

            dataProvider.Fetch(request, series);

            Assert.That(series.Count, Is.EqualTo(1));

            var price = ( Price )series.Single();

            Assert.That(price.Stock.Isin, Is.EqualTo("DE0007664039"));
            Assert.That((( DayPeriod )price.Period).Day.Date, Is.EqualTo(DateTime.Today));
            Assert.That(price.Source, Does.Contain("ariva").IgnoreCase.And.Contains("price").IgnoreCase);
            Assert.That(price.Timestamp.Date, Is.EqualTo(DateTime.Today));
            Assert.That(price.Value, Is.EqualTo(134.356d));
            Assert.That(price.Currency.Symbol, Is.EqualTo("EUR"));
        }