Пример #1
0
        public void UpdateClosingPricesUpdateExistingEntries()
        {
            var priceHistory = new StockPriceHistory(Guid.NewGuid());

            priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 1.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 03), 3.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 05), 5.00m);

            var prices = new StockPrice[]
            {
                new StockPrice(new Date(2000, 01, 03), 10.00m),
                new StockPrice(new Date(2000, 01, 05), 20.00m)
            };

            priceHistory.UpdateClosingPrices(prices);

            var result = priceHistory.GetPrices(new DateRange(Date.MinValue, Date.MaxValue)).ToList();

            result.Should().Equal(new[]
            {
                new StockPrice(new Date(2000, 01, 01), 1.00m),
                new StockPrice(new Date(2000, 01, 03), 10.00m),
                new StockPrice(new Date(2000, 01, 05), 20.00m)
            });
        }
Пример #2
0
        public void GetPricesEmptyList()
        {
            var priceHistory = new StockPriceHistory(Guid.NewGuid());

            var result = priceHistory.GetPrices(new DateRange(new Date(1999, 02, 01), new Date(2000, 06, 01))).ToList();

            result.Should().BeEmpty();
        }
Пример #3
0
        public void GetPricesWhollyAfter()
        {
            var priceHistory = new StockPriceHistory(Guid.NewGuid());

            priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 1.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 03), 3.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 05), 5.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 07), 7.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 09), 9.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 11), 11.00m);

            var result = priceHistory.GetPrices(new DateRange(new Date(2001, 01, 01), new Date(2001, 01, 10))).ToList();

            result.Should().BeEmpty();
        }
Пример #4
0
        public void GetPricesStartBeforeFirstEntryAndEndMatches()
        {
            var priceHistory = new StockPriceHistory(Guid.NewGuid());

            priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 1.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 03), 3.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 05), 5.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 07), 7.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 09), 9.00m);
            priceHistory.UpdateClosingPrice(new Date(2000, 01, 11), 11.00m);

            var result = priceHistory.GetPrices(new DateRange(new Date(1999, 01, 03), new Date(2000, 01, 05))).ToList();

            result.Should().Equal(new[]
            {
                new StockPrice(new Date(2000, 01, 01), 1.00m),
                new StockPrice(new Date(2000, 01, 03), 3.00m),
                new StockPrice(new Date(2000, 01, 05), 5.00m)
            });
        }