Esempio n. 1
0
        public void RequestDirectedToSpecifiedDatasource()
        {
            var req = new EconomicReleaseRequest(DateTime.Now, DataLocation.ExternalOnly, dataSource: _source1.Object.Name);
            var res = _broker.RequestEconomicReleases(req).Result;

            _source1.Verify(x => x.RequestData(It.IsAny<DateTime>(), It.IsAny<DateTime>()));
        }
Esempio n. 2
0
        public void RequestDirectedToDefaultDataSourceIfNotSpecified()
        {
            var req = new EconomicReleaseRequest(DateTime.Now, DataLocation.ExternalOnly, dataSource: null);
            var res = _broker.RequestEconomicReleases(req).Result;

            _source2.Verify(x => x.RequestData(It.IsAny<DateTime>(), It.IsAny<DateTime>()));
        }
Esempio n. 3
0
        public void ExternalResultsReturnedCorrectly()
        {
            var data = new List<EconomicRelease>
            {
                new EconomicRelease("1", "US", "USD", DateTime.Now, Importance.Low, null, null, null),
            };

            _source2
                .Setup(x => x.RequestData(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
                .ReturnsAsync(data);

            var req = new EconomicReleaseRequest(DateTime.Now, DataLocation.ExternalOnly);
            var res = _broker.RequestEconomicReleases(req).Result;

            CollectionAssert.AreEquivalent(data, res);
        }
Esempio n. 4
0
        public void RequestFilterIsApplied()
        {
            var data = new List<EconomicRelease>
            {
                new EconomicRelease("1", "US", "USD", DateTime.Now, Importance.Low, null, null, null),
                new EconomicRelease("2", "UK", "GBP", DateTime.Now, Importance.High, null, null, null),
                new EconomicRelease("3", "CN", "RMB", DateTime.Now, Importance.High, null, null, null),
                new EconomicRelease("4", "EU", "EUR", DateTime.Now, Importance.None, null, null, null),
                new EconomicRelease("5", "US", "USD", DateTime.Now, Importance.Mid, null, null, null),
                new EconomicRelease("6", "US", "USD", DateTime.Now, Importance.High, null, null, null),
            };

            _source2
                .Setup(x => x.RequestData(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
                .ReturnsAsync(data);

            var req = new EconomicReleaseRequest(DateTime.Now, DataLocation.ExternalOnly, x => x.Importance >= Importance.Mid && x.Currency == "USD");
            var res = _broker.RequestEconomicReleases(req).Result;

            CollectionAssert.AreEquivalent(data.AsQueryable().Where(req.Filter).ToList(), res);
        }