コード例 #1
0
        public void BasicService_Max_ReturnsNullWhenInputIsEmpty()
        {
            // Arrange
            var svc         = new BasicService();
            var stockPrices = new StockPrice[0];

            // Act
            var result = svc.Max(stockPrices);

            // Assert
            Assert.IsFalse(result.HasValue);
        }
コード例 #2
0
        public void BasicService_Max_ReturnsFirstOfTwoEqualMaxValues()
        {
            // Arrange
            var svc         = new BasicService();
            var stockPrices = new[]
            {
                sp(1, 1),
                sp(2, 3),   // Should return this one because it is earlier.
                sp(3, 3)    // This one is the same as the previous.
            };

            // Act
            var result = svc.Max(stockPrices);

            // Assert
            Assert.IsTrue(result.HasValue);
            Assert.AreEqual(sp(2, 3), result.Value);
        }
コード例 #3
0
        public void BasicService_Max_ReturnsGreatestOfStockPrices()
        {
            // Arrange
            var svc         = new BasicService();
            var stockPrices = new[]
            {
                sp(1, 1),
                sp(2, 2),
                sp(3, 3) // This one is the greatest.
            };

            // Act
            var result = svc.Max(stockPrices);

            // Assert
            Assert.IsTrue(result.HasValue);
            Assert.AreEqual(sp(3, 3), result.Value);
        }