public async Task Is_Orderbook_Correct() { await _auctionLotManager.AddAsync("client1", "USD", 100, 50); await _auctionLotManager.AddAsync("client1", "USD", 50, 100); await _auctionLotManager.AddAsync("client2", "USD", 1000, 5); await _auctionLotManager.AddAsync("client2", "USD", 100, 10); var orderbook = _auctionLotCacheService.GetOrderbook(); Assert.IsTrue(orderbook.Any(item => item.Price == 100 && item.Volume == 60)); }
public async Task <ResponseModel> AddLot([FromBody] AuctionLot model) { if (string.IsNullOrEmpty(model.ClientId)) { return(ResponseModel.CreateFail(ResponseModel.ErrorCodeType.InvalidInputField, $"{nameof(model.ClientId)} is required")); } if (string.IsNullOrEmpty(model.AssetId)) { return(ResponseModel.CreateFail(ResponseModel.ErrorCodeType.InvalidInputField, $"{nameof(model.AssetId)} is required")); } if (!_settings.Assets.Contains(model.AssetId)) { return(ResponseModel.CreateFail(ResponseModel.ErrorCodeType.InvalidInputField, $"wrong {nameof(model.AssetId)}")); } if (model.Price <= 0) { return(ResponseModel.CreateFail(ResponseModel.ErrorCodeType.InvalidInputField, $"wrong {nameof(model.Price)}")); } if (model.Volume <= 0) { return(ResponseModel.CreateFail(ResponseModel.ErrorCodeType.InvalidInputField, $"wrong {nameof(model.Volume)}")); } //TODO: validate model.ClientId await _auctionLotManager.AddAsync(model.ClientId, model.AssetId, model.Price, model.Volume); return(ResponseModel.CreateOk()); }