public RegisterModifyNotificationHandler ( Action |
||
handler | Action |
|
Résultat | void |
public void ShouldRegisterModifyEventHandlerAndReceiveModifyEvent() { var newOrder = new LimitOrder("ABC", 10, 99.22d, WayEnum.Buy, 3); newOrder.RegisterModifyNotificationHandler((order, oldQuantity, oldPrice) => { Assert.AreEqual(newOrder, order); Assert.AreEqual(11, order.Quantity); Assert.AreEqual(88.44d, order.Price); Assert.AreEqual(10, oldQuantity); Assert.AreEqual(99.22d, oldPrice); }); newOrder.Modify(11, 88.44d); }
public void ShouldRegisterModifyEventHandlerAndUnregister() { var receivedModifedOrders = new List<ILimitOrder>(); var newOrder = new LimitOrder("ABC", 10, 99.22d, WayEnum.Buy, 3); Action<ILimitOrder, int, double> eventHandler; eventHandler = (order, oldQuantity, oldPrice) => { receivedModifedOrders.Add(order); }; newOrder.RegisterModifyNotificationHandler(eventHandler); newOrder.Modify(11, 88.44d); newOrder.UnRegisterModifyNotificationHandler(eventHandler); newOrder.Modify(13, 12.44d); Assert.AreEqual(1, receivedModifedOrders.Count); }
public void ShouldNotMatchOrderWhenMatchingIsSuspendedButMatchWhenSuspensionsIsCancelled() { var executions = new List<INewExecution>(); var orderBookBestBidAsk = new OrderBookBestBidAsk("ABC"); var matchAlgo = new LimitOrderMatchingAlgorithm(new DateService()); matchAlgo.AddExecutionsHandler(executions.Add); var book = new OrderBook("ABC", matchAlgo, marketOrderMatchingAlgorithmMock, orderBookBestBidAsk); var sellOrder1 = new LimitOrder("ABC", 10, 90, WayEnum.Sell, 9); var buyOrder1 = new LimitOrder("ABC", 10, 80, WayEnum.Buy, 9); sellOrder1.RegisterModifyNotificationHandler(book.HandleLimitOrderModify); buyOrder1.RegisterModifyNotificationHandler(book.HandleLimitOrderModify); book.AddLimitOrder(sellOrder1); book.AddLimitOrder(buyOrder1); Assert.AreEqual(0, executions.Count); book.SetSuspendLimitOrderMatchingStatus(true); sellOrder1.Modify(10,70); Assert.AreEqual(0, executions.Count); book.SetSuspendLimitOrderMatchingStatus(true); book.TryMatchLimitOrder(sellOrder1); book.TryMatchLimitOrder(buyOrder1); Assert.AreEqual(1, executions.Count); }
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); }