Esempio n. 1
0
        private CandleMonitor ResetSubject(CandleMonitorFeeds feedData)
        {
            iCountCandleSourceEvents = new CandleSourceEventSummary();

            mockCoinbaseProClient = new Mock <ICoinbaseProClient>();

            fakeWorkflow = StartupWorkflow.ForCandleMonitorOnly();

            var mockCandleDataSource = new Mock <ICandleDataSource>();

            mockCandleDataSource.Setup(o => o.Load(DateTime.UtcNow)).ReturnsAsync(Mock.Of <TimeSeries>());
            mockCandleDataSource.SetupProperty(o => o.LastUpdatedUtc, DateTime.UtcNow.AddDays(-100));

            var mockCandleProvider = new Mock <ICandleProvider>();

            mockCandleProvider.Setup(o => o.Load(Mock.Of <MarketFeedSettings>()).LastUpdatedUtc).Returns(DateTime.UtcNow.AddDays(-100));
            mockCandleProvider.SetupGet(o => o.DataStores[It.IsAny <MarketFeedSettings>()]).Returns(mockCandleDataSource.Object);

            var mockCandleMonitorFeedProvider = new Mock <ICandleMonitorFeedProvider>();

            mockCandleMonitorFeedProvider.Setup(o => o.GetFeeds()).Returns(new List <CandleMonitorFeeds> {
                feedData
            });

            var mockCandleProducer = new Mock <ICandleProducer>();

            setupMockCandleProducer = mockCandleProducer.Setup(o => o.Send(It.IsAny <CandlesReceivedEventArgs>()));

            var fakeAppSettings = Options.Create(new AppSetting());
            var fakeLogger      = NUnitOutputLogger.Create <CandleMonitor>();

            var subject = new CandleMonitor(
                mockCoinbaseProClient.Object,
                fakeWorkflow,
                mockCandleProvider.Object,
                mockCandleMonitorFeedProvider.Object,
                mockCandleProducer.Object,
                fakeAppSettings,
                fakeLogger);

            return(subject);
        }
        private StartupWorkflow(
            bool triggerSocketMonitor,
            bool triggerOrderMonitor,
            bool triggerAccountMonitor,
            bool triggerCandleMonitor,
            bool triggerStrategyMonitor,
            bool triggerOverlayMonitor) : this()
        {
            // See this link for very detailed explanation of how TaskCompletionSource can block
            // https://blogs.msdn.microsoft.com/seteplia/2018/10/01/the-danger-of-taskcompletionsourcet-class/

            if (triggerSocketMonitor)
            {
                SocketMonitor.SetResult(true);
            }
            if (triggerOrderMonitor)
            {
                OrderMonitor.SetResult(true);
            }
            if (triggerAccountMonitor)
            {
                AccountMonitor.SetResult(true);
            }
            if (triggerCandleMonitor)
            {
                CandleMonitor.SetResult(true);
            }
            if (triggerStrategyMonitor)
            {
                StrategyMonitor.SetResult(true);
            }
            if (triggerOverlayMonitor)
            {
                OverlayMonitor.SetResult(true);
            }
        }