Exemplo n.º 1
0
        public async void CanGetSeriesAsync()
        {
            const string response =
                @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<seriess realtime_start=""2012-04-26"" realtime_end=""2012-04-26"">
  <series id=""CPIAUCNS"" realtime_start=""2012-04-26"" realtime_end=""2012-04-26"" title=""Consumer Price Index for All Urban Consumers: All Items"" observation_start=""1913-01-01"" observation_end=""2012-03-01"" frequency=""Monthly"" frequency_short=""M"" units=""Index 1982-84=100"" units_short=""Index 1982-84=100"" seasonal_adjustment=""Not Seasonally Adjusted"" seasonal_adjustment_short=""NSA"" last_updated=""2012-04-13 08:53:00-05"" popularity=""78"" notes=""Handbook of Methods - (http://www.bls.gov/opub/hom/pdf/homch17.pdf) Understanding the CPI: Frequently Asked Questions - (http://stats.bls.gov:80/cpi/cpifaq.htm)""/>
</seriess>";
            var downloader = new MockDownloader(response);
            var fred       = new Fred("key", downloader);
            var series     = await fred.GetSeriesAsync("CPIAUCNS");

            var expectedUrl = "http://api.stlouisfed.org/fred/series?api_key=key&series_id=CPIAUCNS" + RealtimeNow;

            Assert.AreEqual(expectedUrl, downloader.Url);
            Assert.AreEqual("CPIAUCNS", series.Id);
            Assert.AreEqual("Consumer Price Index for All Urban Consumers: All Items", series.Title);
            Assert.AreEqual(new DateTime(2012, 4, 26), series.RealtimeStart);
            Assert.AreEqual(new DateTime(2012, 4, 26), series.RealtimeEnd);
            Assert.AreEqual(new DateTime(1913, 1, 1), series.ObservationStart);
            Assert.AreEqual(new DateTime(2012, 3, 1), series.ObservationEnd);
            Assert.AreEqual(Frequency.Monthly, series.Frequency);
            Assert.AreEqual("Index 1982-84=100", series.Units);
            Assert.AreEqual(false, series.SeasonalAdjusted);
            var expectedDate = new DateTime(2012, 4, 13, 13, 53, 0, DateTimeKind.Utc);

            Assert.AreEqual(expectedDate.ToLocalTime(), series.LastUpdated);
            Assert.AreEqual(78, series.Popularity);
            Assert.AreEqual("Handbook of Methods - (http://www.bls.gov/opub/hom/pdf/homch17.pdf) Understanding the CPI: Frequently Asked Questions - (http://stats.bls.gov:80/cpi/cpifaq.htm)", series.Notes);
        }
Exemplo n.º 2
0
        public async void CanGetSeriesAsync()
        {
            const string response =
                @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<seriess realtime_start=""2012-04-26"" realtime_end=""2012-04-26"">
  <series id=""CPIAUCNS"" realtime_start=""2012-04-26"" realtime_end=""2012-04-26"" title=""Consumer Price Index for All Urban Consumers: All Items"" observation_start=""1913-01-01"" observation_end=""2012-03-01"" frequency=""Monthly"" frequency_short=""M"" units=""Index 1982-84=100"" units_short=""Index 1982-84=100"" seasonal_adjustment=""Not Seasonally Adjusted"" seasonal_adjustment_short=""NSA"" last_updated=""2012-04-13 08:53:00-05"" popularity=""78"" notes=""Handbook of Methods - (http://www.bls.gov/opub/hom/pdf/homch17.pdf) Understanding the CPI: Frequently Asked Questions - (http://stats.bls.gov:80/cpi/cpifaq.htm)""/>
</seriess>";
            var downloader = new MockDownloader(response);
            var fred = new Fred("key", downloader);
            var series = await fred.GetSeriesAsync("CPIAUCNS");
            var expectedUrl = "http://api.stlouisfed.org/fred/series?api_key=key&series_id=CPIAUCNS" + RealtimeNow;
            Assert.AreEqual(expectedUrl, downloader.Url);
            Assert.AreEqual("CPIAUCNS", series.Id);
            Assert.AreEqual("Consumer Price Index for All Urban Consumers: All Items", series.Title);
            Assert.AreEqual(new DateTime(2012, 4, 26), series.RealtimeStart);
            Assert.AreEqual(new DateTime(2012, 4, 26), series.RealtimeEnd);
            Assert.AreEqual(new DateTime(1913, 1, 1), series.ObservationStart);
            Assert.AreEqual(new DateTime(2012, 3, 1), series.ObservationEnd);
            Assert.AreEqual(Frequency.Monthly, series.Frequency);
            Assert.AreEqual("Index 1982-84=100", series.Units);
            Assert.AreEqual(false, series.SeasonalAdjusted);
            var expectedDate = new DateTime(2012, 4, 13, 13, 53, 0, DateTimeKind.Utc);
            Assert.AreEqual(expectedDate.ToLocalTime(), series.LastUpdated);
            Assert.AreEqual(78, series.Popularity);
            Assert.AreEqual("Handbook of Methods - (http://www.bls.gov/opub/hom/pdf/homch17.pdf) Understanding the CPI: Frequently Asked Questions - (http://stats.bls.gov:80/cpi/cpifaq.htm)", series.Notes);
        }