public void SendCancelOrderRequest_IfValidOrderAndTraderIdProvided_ReceiveResponseAndCommandShouldBePublishedOnDisruptor() { CancelOrderResponse response = _orderseService.CancelOrder(new CancelOrderCommand(new OrderId("12"), new TraderId("12"))); _manualResetEvent.WaitOne(3000); Assert.NotNull(response); Assert.NotNull(_cancellation); }
public IHttpActionResult CancelOrder([FromBody] string orderId) { if (log.IsDebugEnabled) { log.Debug("Cancel Order Call: OrderId=" + orderId); } try { //get api key from header var headers = Request.Headers; string apikey = ""; IEnumerable <string> headerParams; if (headers.TryGetValues("Auth", out headerParams)) { string[] auth = headerParams.ToList()[0].Split(','); apikey = auth[0]; } if (log.IsDebugEnabled) { log.Debug("Cancel Order Call: apikey=" + apikey); } if (orderId != string.Empty) { TraderId traderId = new TraderId(_apiKeyInfoAccess.GetUserIdFromApiKey(apikey).ToString()); return(Ok(_orderApplicationService.CancelOrder( new CancelOrderCommand(new OrderId(orderId), traderId)))); } return(BadRequest("OrderId is not provided.")); } catch (InvalidOperationException exception) { if (log.IsErrorEnabled) { log.Error("Cancel Order Call Exception ", exception); } return(BadRequest(exception.Message)); } catch (NullReferenceException exception) { if (log.IsErrorEnabled) { log.Error("Cancel Order Call Exception ", exception); } return(BadRequest(exception.Message)); } catch (InstanceNotFoundException exception) { if (log.IsErrorEnabled) { log.Error("Cancel Order Call Exception ", exception); } return(BadRequest(exception.Message)); } catch (Exception exception) { if (log.IsErrorEnabled) { log.Error("Cancel Order Call Error", exception); } return(InternalServerError()); } }