public void Split_OptimalIsAllAmountToBroker2_ReturnsBroker2Deal()
        {
            var order = new Order(Build_Client(), OrderType.Buy, 100);
            // Broker2 always returns optimal deal
            var broker2OptimalDeal = new Deal(_broker2Mock.Object, 500, 1, 0.01m);
            Setup_Broker1Mock_Estimate(new Deal(_broker1Mock.Object, 1000, 1, 0.01m));
            Setup_Broker2Mock_Estimate(broker2OptimalDeal);
            var expectedDeals = new List<Deal>
            {
                broker2OptimalDeal
            };

            var actualDeals = _orderSplitService.Split(order);

            actualDeals.ShouldAllBeEquivalentTo(expectedDeals);
        }
        public void Split_OptimalIsToSplitOrder_ReturnsBroker2Deal()
        {
            var order = new Order(Build_Client(), OrderType.Buy, 100);
            // Only one combination of Broker1 and Broker2 deals is optimal
            var broker1OptimalDeal = new Deal(_broker1Mock.Object, 60, 1, 0.01m);
            var broker2OptimalDeal = new Deal(_broker2Mock.Object, 40, 1, 0.01m);
            Setup_Broker1Mock_Estimate(new Deal(_broker1Mock.Object, 1000, 1, 0.01m));
            Setup_Broker1Mock_Estimate(60, broker1OptimalDeal);
            Setup_Broker2Mock_Estimate(new Deal(_broker2Mock.Object, 1000, 1, 0.01m));
            Setup_Broker2Mock_Estimate(40, broker2OptimalDeal);
            var expectedDeals = new List<Deal>
            {
                broker1OptimalDeal,
                broker2OptimalDeal
            };

            var actualDeals = _orderSplitService.Split(order);

            actualDeals.ShouldAllBeEquivalentTo(expectedDeals);
        }
Beispiel #3
0
 public void Execute(Deal deal)
 {
     //NOTE: In real application, broker would buy or sell some digicoins here
 }
 public void Execute(Deal deal)
 {
     //NOTE: In real application, broker would buy or sell some digicoins here
 }
 private void Setup_Broker2Mock_Estimate(decimal forInput, Deal result)
 {
     _broker2Mock.Setup(m => m.Estimate(forInput))
         .Returns(result);
 }
 private void Setup_Broker2Mock_Estimate(Deal result)
 {
     _broker2Mock.Setup(m => m.Estimate(It.IsAny<decimal>()))
         .Returns(result);
 }