Ejemplo n.º 1
0
        public void ServiceBase_ChooseBestOrder_ReturnsWhenOrder1Order2AreNull()
        {
            // Arrange
            var svc = new ConcreteServiceBase();

            // Act
            var bestOrder = svc.ChooseBestOrder(null, null);

            // Assert
            Assert.IsNull(bestOrder);
        }
Ejemplo n.º 2
0
        public void ServiceBase_ChooseBestOrder_ReturnsWhenOrder2IsNull()
        {
            // Arrange
            var svc     = new ConcreteServiceBase();
            var anOrder = order(1, 1, 2, 2);

            // Act
            var bestOrder = svc.ChooseBestOrder(anOrder, null);

            // Assert
            Assert.AreSame(anOrder, bestOrder);
        }
Ejemplo n.º 3
0
        public void ServiceBase_ChooseBestOrder_ReturnsWhenOrder2ProfitIsGreater()
        {
            // Arrange
            var svc           = new ConcreteServiceBase();
            var hiProfitOrder = order( // Profit = 9.
                1, 1.00m,
                2, 10.00m);
            var loProfitOrder = order(  // Profit = 1.
                1, 1.00m,
                2, 2.00m);

            // Act
            var bestOrder = svc.ChooseBestOrder(loProfitOrder, hiProfitOrder);

            // Assert
            Assert.AreSame(hiProfitOrder, bestOrder);
        }
Ejemplo n.º 4
0
        public void ServiceBase_ChooseBestOrder_ReturnsWhenOrder1DurationShorter()
        {
            // Arrange
            var svc        = new ConcreteServiceBase();
            var shortOrder = order( // Duration = 1day.
                1, 1.00m,
                2, 2.00m);
            var longOrder = order(  // Duration = 8days.
                1, 1.00m,
                9, 2.00m);

            // Profits must be equal.
            Assert.AreEqual(shortOrder.Profit, longOrder.Profit);

            // Act
            var bestOrder = svc.ChooseBestOrder(shortOrder, longOrder);

            // Assert
            Assert.AreSame(shortOrder, bestOrder);
        }
Ejemplo n.º 5
0
        public void ServiceBase_ChooseBestOrder_ReturnsWhenOrder2IsEarlier()
        {
            // Arrange
            var svc        = new ConcreteServiceBase();
            var earlyOrder = order(
                1, 1.00m,
                2, 2.00m);
            var lateOrder = order(
                3, 1.00m,
                4, 2.00m);

            // Profits and duration must be equal.
            Assert.AreEqual(earlyOrder.Profit, lateOrder.Profit);
            Assert.AreEqual(earlyOrder.Duration, lateOrder.Duration);

            // Act
            var bestOrder = svc.ChooseBestOrder(lateOrder, earlyOrder);

            // Assert
            Assert.AreSame(earlyOrder, bestOrder);
        }
Ejemplo n.º 6
0
        public void ServiceBase_ChooseBestOrder_ReturnsWhenAllThingsAreEqual()
        {
            // Arrange
            var svc    = new ConcreteServiceBase();
            var order1 = order(
                1, 1.00m,
                2, 2.00m);
            var order2 = order(
                1, 1.00m,
                2, 2.00m);

            // Profits and duration must be equal.
            Assert.AreEqual(order1.Profit, order2.Profit);
            Assert.AreEqual(order1.Duration, order2.Duration);
            Assert.AreEqual(order1.Buy.DateTime, order2.Buy.DateTime);

            // Act
            var bestOrder = svc.ChooseBestOrder(order1, order2);

            // Assert
            Assert.AreSame(order1, bestOrder);
        }