예제 #1
0
        public void CheckOrder_NullOrderId_ThrowsException()
        {
            var binanceClient = new Mock <IBinanceClient>();
            var subject       = new Binance(Mock.Of <IWebSocket>(), binanceClient.Object, Mock.Of <ITime>());

            var e = Expect.ThrowAsync <ArgumentException>(async() =>
            {
                await subject.CheckOrder(new Order());
            });

            Assert.AreEqual("order", e.ParamName);
        }
예제 #2
0
        public void CheckOrder_NotInitialized_ThrowsException()
        {
            var binanceClient = new Mock <IBinanceClient>();
            var subject       = new Binance(Mock.Of <IWebSocket>(), binanceClient.Object, Mock.Of <ITime>());

            var e = Expect.ThrowAsync <InvalidOperationException>(async() =>
            {
                await subject.CheckOrder(new Order()
                {
                    Id = "123"
                });
            });

            Assert.AreEqual("Cannot CheckOrder until exchange has been Initialized", e.Message);
        }
예제 #3
0
        public void CheckOrder_OrderFilled_ReturnsOrderWithSameIDMarkedFilled()
        {
            var binanceClient = InitBinanceClientMock();

            binanceClient.Setup(m => m.QueryOrder(It.Is <QueryOrderRequest>(q =>
                                                                            q.OriginalClientOrderId == "123" &&
                                                                            q.Symbol == "BTCUSDT"), 5000))
            .ReturnsAsync(new OrderResponse()
            {
                Status = OrderStatus.Filled
            });
            var subject = new Binance(Mock.Of <IWebSocket>(), binanceClient.Object, Mock.Of <ITime>());

            subject.Initialize(Assets.BTC, Assets.USDT).Wait();

            var result = subject.CheckOrder(new Order()
            {
                Id = "123"
            }).Result;

            Assert.AreEqual("123", result.Id);
            Assert.IsTrue(result.Fulfilled);
        }