public void add_order_basket_item()
        {
            OrderBroker broker = new OrderBroker(new ApiBrokerConfig {
                EndPoint = ConfigurationManager.AppSettings["apiEndpoint"]
            });
            var result = broker.AddOrderBasketItem(new OrderBasketItemPost
            {
                RetailerId      = 1,
                OrderBasketItem = new OrderBasketItem
                {
                    OrderBasketId = 1,
                    ProductId     = 1,
                    BarCode       = "ABCD",
                    ProductCode   = "MILK",
                    ProductName   = "2L Milk",
                    NumberOfUnits = 2,
                    PricePerUnit  = 15,
                    UnitOfMeasure = "Bottle",
                    TotalPrice    = 30
                }
            });


            Assert.NotNull(result);
            Assert.IsTrue(result.IsCommandSuccess);
            Assert.IsTrue(result.IsCallSuccess);
        }
        public void get_items_for_order_basket()
        {
            OrderBroker broker = new OrderBroker(new ApiBrokerConfig {
                EndPoint = ConfigurationManager.AppSettings["apiEndpoint"]
            });
            var result = broker.AllItemsForOrderBasket(1, 1);

            Assert.NotNull(result);
            Assert.True(result.Count > 0);
        }
        public void broker_order_getallforretailer()
        {
            OrderBroker broker = new OrderBroker(new ApiBrokerConfig {
                EndPoint = ConfigurationManager.AppSettings["apiEndpoint"]
            });
            var orderBaskets = broker.AllOrderBasketForRetailer(1);

            Assert.IsNotNull(orderBaskets);
            Assert.IsTrue(orderBaskets.Count > 1);
        }
        public void finalise_order_successfully()
        {
            OrderBroker broker = new OrderBroker(new ApiBrokerConfig {
                EndPoint = ConfigurationManager.AppSettings["apiEndpoint"]
            });
            var result = broker.FinaliseOrder(new FinaliseOrderPost {
                OrderBasketId = 1, RetailerId = 1
            });

            Assert.NotNull(result);
            Assert.IsTrue(result.IsCallSuccess);
            Assert.IsTrue(result.IsCommandSuccess);
        }
示例#5
0
        public void Ctor_AssignsVariables_Correctly()
        {
            var id        = "broker-id";
            var reddeerId = "reddeer-id";
            var name      = "broker-name";
            var createdOn = DateTime.UtcNow;
            var live      = true;

            var broker = new OrderBroker(id, reddeerId, name, createdOn, live);

            Assert.AreEqual(id, broker.Id);
            Assert.AreEqual(reddeerId, broker.ReddeerId);
            Assert.AreEqual(name, broker.Name);
            Assert.AreEqual(createdOn, broker.CreatedOn);
            Assert.AreEqual(live, broker.Live);
        }
 public OrderService()
 {
     _orderBroker      = new OrderBroker();
     _productBroker    = new ProductBroker();
     _sessionContainer = new SessionContainer();
 }
示例#7
0
        public void ToString_YieldsExpected_Value()
        {
            var placedDate    = new DateTime(2019, 1, 1, 1, 1, 1);
            var bookedDate    = new DateTime(2019, 1, 1, 1, 1, 1);
            var amendedDate   = new DateTime(2019, 1, 1, 1, 1, 1);
            var rejectedDate  = new DateTime(2019, 1, 1, 1, 1, 1);
            var cancelledDate = new DateTime(2019, 1, 1, 1, 1, 1);
            var filledDate    = new DateTime(2019, 1, 1, 1, 1, 1);

            var fi                   = new FinancialInstrument();
            var market               = new Market("market-id", "XLON", "London Stock Exchange", MarketTypes.STOCKEXCHANGE);
            var reddeerOrderId       = 124;
            var orderId              = "order-id";
            var createdDate          = new DateTime(2019, 09, 19, 1, 1, 1);
            var orderVersion         = "version-1";
            var orderVersionLinkId   = "version-link-id-1";
            var orderGroupId         = "order-group-id";
            var orderTypes           = OrderTypes.MARKET;
            var orderDirection       = OrderDirections.SHORT;
            var currency             = new Currency("GBP");
            var settlementCurrency   = new Currency("USD");
            var cleanDirty           = OrderCleanDirty.DIRTY;
            var accumInterest        = 1241.3m;
            var limitPrice           = new Money(99, "GBP");
            var averageFillPrice     = new Money(101, "GBP");
            var orderedVolume        = 1234m;
            var filledVolume         = 4321m;
            var traderId             = "abcdef";
            var traderName           = "Mr Trader";
            var clearingAgent        = "Goldman";
            var dealingInstruction   = "ASAP";
            var broker               = new OrderBroker("broker-1", "2", "Brokerage Inc", DateTime.UtcNow, true);
            var optionStrikePrice    = new Money(30, "USD");
            var optionExpirationDate = new DateTime(2019, 08, 19, 1, 1, 1);
            var optionEurAmer        = OptionEuropeanAmerican.AMERICAN;
            var trades               = new DealerOrder[0];

            var order = new Order(
                fi,
                market,
                reddeerOrderId,
                orderId,
                createdDate,
                orderVersion,
                orderVersionLinkId,
                orderGroupId,
                placedDate,
                bookedDate,
                amendedDate,
                rejectedDate,
                cancelledDate,
                filledDate,
                orderTypes,
                orderDirection,
                currency,
                settlementCurrency,
                cleanDirty,
                accumInterest,
                limitPrice,
                averageFillPrice,
                orderedVolume,
                filledVolume,
                traderId,
                traderName,
                clearingAgent,
                dealingInstruction,
                broker,
                optionStrikePrice,
                optionExpirationDate,
                optionEurAmer,
                trades);

            var result = order.ToString();

            Assert.AreEqual(" |London Stock Exchange | Cancelled | ordered-1234 | filled-4321 | (GBP) 101", result);
        }
示例#8
0
        public void Ctor_AssignsVariables_Correctly()
        {
            var placedDate    = new DateTime(2019, 1, 1, 1, 1, 1);
            var bookedDate    = new DateTime(2019, 1, 1, 1, 1, 1);
            var amendedDate   = new DateTime(2019, 1, 1, 1, 1, 1);
            var rejectedDate  = new DateTime(2019, 1, 1, 1, 1, 1);
            var cancelledDate = new DateTime(2019, 1, 1, 1, 1, 1);
            var filledDate    = new DateTime(2019, 1, 1, 1, 1, 1);

            var fi                   = new FinancialInstrument();
            var market               = new Market("market-id", "XLON", "London Stock Exchange", MarketTypes.STOCKEXCHANGE);
            var reddeerOrderId       = 124;
            var orderId              = "order-id";
            var createdDate          = new DateTime(2019, 09, 19, 1, 1, 1);
            var orderVersion         = "version-1";
            var orderVersionLinkId   = "version-link-id-1";
            var orderGroupId         = "order-group-id";
            var orderTypes           = OrderTypes.MARKET;
            var orderDirection       = OrderDirections.SHORT;
            var currency             = new Currency("GBP");
            var settlementCurrency   = new Currency("USD");
            var cleanDirty           = OrderCleanDirty.DIRTY;
            var accumInterest        = 1241.3m;
            var limitPrice           = new Money(99, "GBP");
            var averageFillPrice     = new Money(101, "GBP");
            var orderedVolume        = 1234m;
            var filledVolume         = 4321m;
            var traderId             = "abcdef";
            var traderName           = "Mr Trader";
            var clearingAgent        = "Goldman";
            var dealingInstruction   = "ASAP";
            var broker               = new OrderBroker("broker-1", "2", "Brokerage Inc", DateTime.UtcNow, true);
            var optionStrikePrice    = new Money(30, "USD");
            var optionExpirationDate = new DateTime(2019, 08, 19, 1, 1, 1);
            var optionEurAmer        = OptionEuropeanAmerican.AMERICAN;
            var trades               = new DealerOrder[0];

            var order = new Order(
                fi,
                market,
                reddeerOrderId,
                orderId,
                createdDate,
                orderVersion,
                orderVersionLinkId,
                orderGroupId,
                placedDate,
                bookedDate,
                amendedDate,
                rejectedDate,
                cancelledDate,
                filledDate,
                orderTypes,
                orderDirection,
                currency,
                settlementCurrency,
                cleanDirty,
                accumInterest,
                limitPrice,
                averageFillPrice,
                orderedVolume,
                filledVolume,
                traderId,
                traderName,
                clearingAgent,
                dealingInstruction,
                broker,
                optionStrikePrice,
                optionExpirationDate,
                optionEurAmer,
                trades);

            Assert.AreEqual(fi, order.Instrument);
            Assert.AreEqual(market, order.Market);
            Assert.AreEqual(reddeerOrderId, order.ReddeerOrderId);
            Assert.AreEqual(orderId, order.OrderId);
            Assert.AreEqual(orderVersion, order.OrderVersion);
            Assert.AreEqual(orderVersionLinkId, order.OrderVersionLinkId);
            Assert.AreEqual(orderGroupId, order.OrderGroupId);
            Assert.AreEqual(optionStrikePrice, order.OrderOptionStrikePrice);
            Assert.AreEqual(optionExpirationDate, order.OrderOptionExpirationDate);
            Assert.AreEqual(optionEurAmer, order.OrderOptionEuropeanAmerican);
            Assert.AreEqual(createdDate, order.CreatedDate);
            Assert.AreEqual(orderTypes, order.OrderType);
            Assert.AreEqual(orderDirection, order.OrderDirection);
            Assert.AreEqual(currency, order.OrderCurrency);
            Assert.AreEqual(settlementCurrency, order.OrderSettlementCurrency);
            Assert.AreEqual(cleanDirty, order.OrderCleanDirty);
            Assert.AreEqual(accumInterest, order.OrderAccumulatedInterest);
            Assert.AreEqual(limitPrice, order.OrderLimitPrice);
            Assert.AreEqual(averageFillPrice, order.OrderAverageFillPrice);
            Assert.AreEqual(traderId, order.OrderTraderId);
            Assert.AreEqual(traderName, order.OrderTraderName);
            Assert.AreEqual(clearingAgent, order.OrderClearingAgent);
            Assert.AreEqual(dealingInstruction, order.OrderDealingInstructions);
            Assert.AreEqual(broker, order.OrderBroker);
            Assert.AreEqual(trades, order.DealerOrders);
            Assert.AreEqual(orderedVolume, order.OrderOrderedVolume);
            Assert.AreEqual(filledVolume, order.OrderFilledVolume);
            Assert.AreEqual(string.Empty, order.OrderFund);
            Assert.AreEqual(string.Empty, order.OrderStrategy);
            Assert.AreEqual(string.Empty, order.OrderClientAccountAttributionId);
            Assert.AreEqual(false, order.IsInputBatch);
            Assert.AreEqual(0, order.BatchSize);
            Assert.AreEqual(null, order.InputBatchId);
        }