Пример #1
0
    public async Task GetObservationUpdatesTest()
    {
        List <Observation> data = await FredClient.GetObservationUpdates("GNPCA", new DateTime(2020, 1, 1), new DateTime(2020, 12, 31));

        Assert.IsNotNull(data);

        data = await FredClient.GetObservationUpdates(DOES_NOT_EXIST, new DateTime(2020, 1, 1), new DateTime(2020, 12, 31));

        Assert.IsNull(data);
    }
Пример #2
0
    public async Task Download_five_symbols()
    {
        string[] symbols   = new string[] { "LEU0252881600Q", "CPIAUCSL", "GDP", "M2V", "BAA10Y" };
        DateTime startDate = new DateTime(2000, 1, 1);
        DateTime endDate   = new DateTime(2000, 12, 31);
        ConcurrentBag <Observation> observations = new ConcurrentBag <Observation>();

        Task[] tasks = new Task[symbols.Length];

        for (int i = 0; i < symbols.Length; i++)
        {
            tasks[i] = FredClient.GetObservationUpdates(symbols[i], startDate, endDate)
                       .ContinueWith(x => x.Result.ForEach(o => observations.Add(o)));
        }

        Task  result = Task.WhenAll(tasks);
        await result;

        Assert.IsFalse(result.IsFaulted);
        Assert.AreEqual(5, observations.GroupBy(x => x.Symbol).Count());
    }