コード例 #1
0
ファイル: DemoBrokerTests.cs プロジェクト: tevert/Trader
        private DemoBroker InitBroker(Mock <IExchange> socketMock)
        {
            var now = DateTime.Now;

            socketMock.SetupSequence(m => m.GetCurrentPrice())
            .ReturnsAsync(new Sample {
                Value = 1.000M, DateTime = now
            })
            .ReturnsAsync(new Sample {
                Value = 1.000M, DateTime = now + TimeSpan.FromMinutes(9)
            })
            .ReturnsAsync(new Sample {
                Value = 1.000M, DateTime = now + TimeSpan.FromMinutes(10)
            });

            var subject = new DemoBroker(socketMock.Object);

            subject.InitializeAsync(Assets.DOGE, Assets.DOGE).Wait();

            socketMock.Reset();
            return(subject);
        }
コード例 #2
0
ファイル: DemoBrokerTests.cs プロジェクト: tevert/Trader
        public void Initialize_StartValueSmaller_ReturnsTrue()
        {
            var now          = DateTime.Now;
            var exchangeMock = new Mock <IExchange>();

            exchangeMock.SetupSequence(m => m.GetCurrentPrice())
            .ReturnsAsync(new Sample {
                Value = 100, DateTime = now
            })
            .ReturnsAsync(new Sample {
                Value = 99, DateTime = now + TimeSpan.FromMinutes(9)
            })
            .ReturnsAsync(new Sample {
                Value = 101, DateTime = now + TimeSpan.FromMinutes(10)
            });

            var subject = new DemoBroker(exchangeMock.Object);

            var result = subject.InitializeAsync(Assets.DOGE, Assets.BTC).Result;

            Assert.IsTrue(result);
        }
コード例 #3
0
ファイル: DemoBrokerTests.cs プロジェクト: tevert/Trader
        public void Initialize_Connects_WarmsUpFor10Minutes()
        {
            var now          = DateTime.Now;
            var exchangeMock = new Mock <IExchange>();

            exchangeMock.SetupSequence(m => m.GetCurrentPrice())
            .ReturnsAsync(new Sample {
                Value = 100, DateTime = now
            })
            .ReturnsAsync(new Sample {
                Value = 100, DateTime = now + TimeSpan.FromMinutes(9)
            })
            .ReturnsAsync(new Sample {
                Value = 100, DateTime = now + TimeSpan.FromMinutes(10)
            });

            var subject = new DemoBroker(exchangeMock.Object);

            var result = subject.InitializeAsync(Assets.DOGE, Assets.BTC).Result;

            exchangeMock.Verify(m => m.Initialize(Assets.DOGE, Assets.BTC));
            exchangeMock.Verify(m => m.GetCurrentPrice(), Times.Exactly(3));
        }