public async Task ShouldCreateOrder() { var client = new OrdersService.OrdersServiceClient(_fixture.GrpcChannel); var placeOrderRequest = new CreateOrderRequest { Order = new Order { Count = 10, DeliveryUuid = Guid.NewGuid().ToString(), ProductUuid = Guid.NewGuid().ToString(), }, }; var response = await client.CreateOrderAsync(placeOrderRequest); placeOrderRequest.Order.OrderUuid = response.Order.OrderUuid;//normalise response var persistedOrder = await client.GetOrderAsync(new GetOrderRequest { OrderUuid = response.Order.OrderUuid, }); persistedOrder.Order.Should().Be(placeOrderRequest.Order); }
public async Task SubscribeChildOrdersAsync(int instrumentId, Func <int, CollectionReceivedEventArgs <BitFlyerChildOrder>, bool> callback, DateTime?deadline = null, CancellationToken cancellationToken = default) { using (await _Client.OpenAsync().ConfigureAwait(false)) using (var res = new OrdersService.OrdersServiceClient(_Client.Channel).SubscribeChildOrders( new Models.Remoting.InstrumentIdRequest() { InstrumentId = instrumentId }, deadline: deadline, cancellationToken: cancellationToken)) { while (await res.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false) && !cancellationToken.IsCancellationRequested) { var c = res.ResponseStream.Current; var m = new CollectionReceivedEventArgs <BitFlyerChildOrder>( c.Action, c.Orders.Select(e => new BitFlyerChildOrder(instrumentId, e)).Where(e => e.IsValid)); if (callback?.Invoke(instrumentId, m) != true) { return; } } } }
public OrderService(OrdersService.OrdersServiceClient grpClient) { this.grpClient = grpClient; }