Пример #1
0
        public void ShouldRegisterDeleteHandlerAndRaiseDeleteEvent()
        {
            var receivedDeletedOrders = new List <ILimitOrder>();
            var newOrder = new LimitOrder("ABC", 10, 99.22d, WayEnum.Buy, 3);

            newOrder.RegisterDeleteNotificationHandler(receivedDeletedOrders.Add);
            newOrder.Delete();
            Assert.AreEqual(1, receivedDeletedOrders.Count);
        }
Пример #2
0
        public void ShouldUnregisterAllHandlersOnDelete()
        {
            var receivedDeletedOrders = new List <ILimitOrder>();
            var receivedModifyOrders  = new List <ILimitOrder>();
            var newOrder = new LimitOrder("ABC", 10, 99.22d, WayEnum.Buy, 3);

            Action <ILimitOrder, int, double> modifyEventHandler;

            modifyEventHandler = (order, oldQuantity, oldPrice) =>
            {
                receivedModifyOrders.Add(order);
            };


            newOrder.RegisterDeleteNotificationHandler(receivedDeletedOrders.Add);
            newOrder.RegisterModifyNotificationHandler(modifyEventHandler);
            newOrder.Delete();
            newOrder.Modify(90, 20);
            newOrder.Delete();
            Assert.AreEqual(1, receivedDeletedOrders.Count);
            Assert.AreEqual(0, receivedModifyOrders.Count);
        }
Пример #3
0
        public void BookShouldRemoveSlotWhenOrderIsDeleted()
        {
            var orderBookBestBidAsk = new OrderBookBestBidAsk("ABC");
            var book = new OrderBook("ABC", limitOrderMatchingAlgorithmMock.Object, marketOrderMatchingAlgorithmMock.Object, orderBookBestBidAsk);

            var buyOrder = new LimitOrder("ABC", 10, 90, WayEnum.Buy, 9);

            book.AddLimitOrder(buyOrder);

            Assert.IsTrue(book.PriceSlots.ContainsKey(90));
            Assert.AreEqual(buyOrder, book.PriceSlots[90].BuyOrders[0]);

            buyOrder.Delete();

            Assert.IsFalse(book.PriceSlots.ContainsKey(90));
        }