public void GetInvestmentCandidates_NotEnoughtPeriods_ReturnsNothing()
        {
            var stock = new Stock
            {
                Id          = "STK.PLC",
                Name        = "STOCK PLC",
                Description = "The Test Stock Price"
            };

            var history = new StockPriceHistory
            {
                Stock  = stock,
                Prices = new Dictionary <Period, Price>()
            };

            var currentDate   = DateTime.UtcNow.AddMinutes(10);
            var lastPeriodEnd = DateTime.Parse(currentDate.ToString("dd MMMM yyyy HH:00:00"));

            history.Prices.Add(new Period {
                Id = 5, To = lastPeriodEnd.AddHours(-2)
            }, new Price {
                Mid = 27.25m
            });
            history.Prices.Add(new Period {
                Id = 6, To = lastPeriodEnd.AddHours(-1)
            }, new Price {
                Mid = 18.50m
            });
            history.Prices.Add(new Period {
                Id = 7, To = lastPeriodEnd.AddHours(0)
            }, new Price {
                Mid = 13.40m
            });

            var stockPriceProvider = new Mock <IStockHistoryDataProvider>();

            stockPriceProvider.Setup(x => x.GetStockHistory(stock, 5)).Returns(history);

            var filter = new MinimumRateOfChangeStockFilter(stockPriceProvider.Object, 5, 25m, 25m);

            var results = filter.GetInvestmentCandidates(new Stock[] { stock });

            Assert.AreEqual(0, results.Count());
        }
        public void GetInvestmentCandidates_RateOfGrowthInsufficient_ReturnsNothing()
        {
            var stock = new Stock
            {
                Identifier  = "STK.PLC",
                Name        = "STOCK PLC",
                Description = "The Test Stock Price"
            };

            var history = new StockPriceHistory
            {
                Stock  = stock,
                Prices = new Dictionary <Period, Price>()
            };

            var currentDate   = DateTime.UtcNow.AddMinutes(10);
            var lastPeriodEnd = DateTime.Parse(currentDate.ToString("dd MMMM yyyy HH:00:00"));

            history.Prices.Add(new Period {
                Id = 1, To = lastPeriodEnd.AddHours(-6)
            }, new Price {
                Bid = 25.20m, Offer = 25.26m
            });
            history.Prices.Add(new Period {
                Id = 2, To = lastPeriodEnd.AddHours(-5)
            }, new Price {
                Bid = 26.20m, Offer = 26.26m
            });
            history.Prices.Add(new Period {
                Id = 3, To = lastPeriodEnd.AddHours(-4)
            }, new Price {
                Bid = 28.20m, Offer = 28.26m
            });
            history.Prices.Add(new Period {
                Id = 4, To = lastPeriodEnd.AddHours(-3)
            }, new Price {
                Bid = 30.20m, Offer = 30.26m
            });
            history.Prices.Add(new Period {
                Id = 5, To = lastPeriodEnd.AddHours(-2)
            }, new Price {
                Bid = 30.00m, Offer = 30.50m
            });
            history.Prices.Add(new Period {
                Id = 6, To = lastPeriodEnd.AddHours(-1)
            }, new Price {
                Bid = 31.00m, Offer = 32.00m
            });
            history.Prices.Add(new Period {
                Id = 7, To = lastPeriodEnd.AddHours(0)
            }, new Price {
                Bid = 35.00m, Offer = 35.80m
            });

            var stockPriceProvider = new Mock <IStockHistoryDataProvider>();

            stockPriceProvider.Setup(x => x.GetStockHistory(stock, 5)).Returns(history);

            var filter = new MinimumRateOfChangeStockFilter(stockPriceProvider.Object, 5, 35m, 35m);

            var results = filter.GetInvestmentCandidates(new Stock[] { stock });

            Assert.AreEqual(0, results.Count());
        }