コード例 #1
0
        public void EfficientService_PopSellPrices_PopsSellPricesThatAreLessThanOrEqualToTheBuyDate()
        {
            // Arrange
            var svc        = new EfficientService();
            var sellPrices = new Stack <StockPrice>(new[]
            {
                sp(1, 1),
                sp(2, 1),
                sp(3, 1),
                // We'll use a buy date of 1/3/2019, so this should be the first
                // element in the stack once we're done.
                sp(4, 1),
                sp(5, 1),
                sp(6, 1),
            }.Reverse());   // It's a stack, so we have to reverse it.

            // Act
            svc.PopSellPrices(sellPrices, sp(3, 1).DateTime);

            // Assert
            Assert.AreEqual(3, sellPrices.Count);
            Assert.AreEqual(sp(4, 1), sellPrices.Pop());
            Assert.AreEqual(sp(5, 1), sellPrices.Pop());
            Assert.AreEqual(sp(6, 1), sellPrices.Pop());
        }