public void Sell_ZeroQuantity_ThrowsException() { var subject = new Binance(Mock.Of <IWebSocket>(), Mock.Of <IBinanceClient>(), Mock.Of <ITime>()); var e = Expect.ThrowAsync <ArgumentException>(async() => { await subject.Sell(new Sample(), 0); }); Assert.AreEqual("quantity", e.ParamName); }
public void Sell_NotInitialized_ThrowsException() { var subject = new Binance(Mock.Of <IWebSocket>(), Mock.Of <IBinanceClient>(), Mock.Of <ITime>()); var e = Expect.ThrowAsync <InvalidOperationException>(async() => { await subject.Sell(new Sample(), 1); }); Assert.AreEqual("Cannot Sell until Initialized", e.Message); }
public void Sell_NullRate_ThrowsException() { var subject = new Binance(Mock.Of <IWebSocket>(), Mock.Of <IBinanceClient>(), Mock.Of <ITime>()); var e = Expect.ThrowAsync <ArgumentNullException>(async() => { await subject.Sell(null, 1); }); Assert.AreEqual("rate", e.ParamName); }
public void Sell_TransactionLessThanMinQuantity_ReturnsNull() { var binanceClient = InitBinanceClientMock(); var subject = new Binance(Mock.Of <IWebSocket>(), binanceClient.Object, Mock.Of <ITime>()); subject.Initialize(Assets.BTC, Assets.USDT).Wait(); var result = subject.Sell(new Sample() { Value = 0.0001M }, 0.000099M).Result; Assert.IsNull(result); binanceClient.Verify(m => m.CreateOrder(It.IsAny <CreateOrderRequest>()), Times.Never()); }
public void Sell_TransactionMoreThanMinQuantity_SubmitsAndReturnsOrder() { var binanceClient = InitBinanceClientMock(); binanceClient.Setup(m => m.CreateOrder(It.Is <CreateOrderRequest>(r => r.Symbol == "BTCUSDT" && r.Side == OrderSide.Sell && r.Type == OrderType.Market && r.Quantity == 0.0005M ))).ReturnsAsync(new ResultCreateOrderResponse() { ClientOrderId = "123" }); var subject = new Binance(Mock.Of <IWebSocket>(), binanceClient.Object, Mock.Of <ITime>()); subject.Initialize(Assets.BTC, Assets.USDT).Wait(); var result = subject.Sell(new Sample() { Value = 0.0001M }, 0.0005M).Result; Assert.AreEqual("123", result.Id); }