public void ResultsFromAllSignalDetectorsInserted()
        {
            this.mockDatapointRepository.Setup(o => o.FindAll(Symbol)).Returns(new List<DataPoints>());
            this.mockCandlestickSignalRepository.Setup(o => o.FindAllForCompany(Symbol)).Returns(new List<CandleStickSignal>());

            var mockSignalDetector1 = SetupSignalDetectorMock(new[] { DateTime.Today, DateTime.Today.AddDays(7) }, 1);
            var mockSignalDetector2 = SetupSignalDetectorMock(new[] {DateTime.Today.AddDays(1), DateTime.Today.AddDays(5)}, 2);

            this.candlestickPatternRecogniserFactory.Setup(o => o.CreateAll(It.IsAny<IEnumerable<DataPoints>>()))
                .Returns(new[] {mockSignalDetector1.Object, mockSignalDetector2.Object});

            var service = new CandleStickSignalManagementService(
                this.mockDatapointRepository.Object,
                this.mockCandlestickSignalRepository.Object,
                this.mockCompanyRepository.Object,
                this.candlestickPatternRecogniserFactory.Object
                );

            service.GenerateLatestSignals(Symbol, DateTime.MinValue);
            this.VerifyCandlestickRepositoryCalledWith(1, DateTime.Today);
            this.VerifyCandlestickRepositoryCalledWith(1, DateTime.Today.AddDays(7));
            this.VerifyCandlestickRepositoryCalledWith(2, DateTime.Today.AddDays(1));
            this.VerifyCandlestickRepositoryCalledWith(2, DateTime.Today.AddDays(5));
        }
        public void SignalAlreadyDetectedForDateTest()
        {
            var candlestickSignalsInDb = new[] {CandleStickSignal.Create(Symbol, DateTime.Today, 1)};
            this.mockCandlestickSignalRepository.Setup(o => o.FindAllForCompany(Symbol)).Returns(candlestickSignalsInDb);
            this.mockDatapointRepository.Setup(o => o.FindAll(Symbol)).Returns(new List<DataPoints>());
            var mockSignalDetector = SetupSignalDetectorMock(new[] { DateTime.Today, DateTime.Today.AddDays(5) }, 1);

            this.candlestickPatternRecogniserFactory.Setup(o => o.CreateAll(It.IsAny<IEnumerable<DataPoints>>()))
                .Returns(new[] { mockSignalDetector.Object });

            var service = new CandleStickSignalManagementService(
                this.mockDatapointRepository.Object,
                this.mockCandlestickSignalRepository.Object,
                this.mockCompanyRepository.Object,
                this.candlestickPatternRecogniserFactory.Object
                );

            service.GenerateLatestSignals(Symbol, DateTime.MinValue);
            this.mockCandlestickSignalRepository.Verify(o => o.InsertAll(It.Is<IEnumerable<CandleStickSignal>>(l => l.Count() == 1)));
            this.VerifyCandlestickRepositoryCalledWith(1, DateTime.Today.AddDays(5));
        }