public void GetInvestmentCandidates_MultipleFilters_ExecutesAlLFilters()
		{
			var stocks = new Stock[]
			{
				new Stock { Id = "STK.1" }, 
				new Stock { Id = "STK.2" }, 
			};

			var filter1 = new Mock<IStockFilter>();
			filter1.Setup(x => x.GetInvestmentCandidates(stocks)).Returns(stocks);

			var filter2 = new Mock<IStockFilter>();
			filter2.Setup(x => x.GetInvestmentCandidates(stocks)).Returns(stocks);

			var filter3 = new Mock<IStockFilter>();
			filter3.Setup(x => x.GetInvestmentCandidates(stocks)).Returns(stocks);

			var compositeFilter = new CompositeStockFilter(filter1.Object, filter2.Object, filter3.Object);

			var result = compositeFilter.GetInvestmentCandidates(stocks);

			filter1.Verify(x => x.GetInvestmentCandidates(stocks), Times.Once());
			filter2.Verify(x => x.GetInvestmentCandidates(stocks), Times.Once());
			filter3.Verify(x => x.GetInvestmentCandidates(stocks), Times.Once());

			Assert.AreEqual(2, stocks.Count());
			Assert.IsTrue(stocks.Any(x => x.Id.Equals("STK.1")));
			Assert.IsTrue(stocks.Any(x => x.Id.Equals("STK.2")));
		}
		public void GetInvestmentCandidates_RateOfGrowthInsufficient_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 = 1, To = lastPeriodEnd.AddHours(-6) }, new Price { Mid = 25.23m });
			history.Prices.Add(new Period { Id = 2, To = lastPeriodEnd.AddHours(-5) }, new Price { Mid = 26.23m });
			history.Prices.Add(new Period { Id = 3, To = lastPeriodEnd.AddHours(-4) }, new Price { Mid = 28.23m });
			history.Prices.Add(new Period { Id = 4, To = lastPeriodEnd.AddHours(-3) }, new Price { Mid = 30.23m });
			history.Prices.Add(new Period { Id = 5, To = lastPeriodEnd.AddHours(-2) }, new Price { Mid = 30.25m });
			history.Prices.Add(new Period { Id = 6, To = lastPeriodEnd.AddHours(-1) }, new Price { Mid = 31.50m });
			history.Prices.Add(new Period { Id = 7, To = lastPeriodEnd.AddHours(0) }, new Price { Mid = 35.40m });

			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());
		}
		public void GetInvestmentCandidates_StockNotAlreadyInvested_ReturnsStock()
		{
			var stock = new Stock
			{
				Id = "STK.PLC",
				Name = "STOCK PLC",
				Description = "The Test Stock Price"
			};

			var stocks = new Stock[] { stock };

			var bet = new Bet
			{
				Stock = new Stock
				{
					Id = "NSH.PLC", 
					Name="NOTHING-TO-SEE-HERE PLC", 
					Description = "The Test Stock Price"
				}
			};

			var portfolioProvider = new Mock<IPortfolioDataProvider>();
			portfolioProvider.Setup(x => x.GetExistingBets()).Returns(new Bet[] { bet });

			var filter = new ExistingStockRemovalFilter(portfolioProvider.Object);

			var retVal = filter.GetInvestmentCandidates(stocks);

			Assert.AreEqual(1, retVal.Count());
			Assert.IsTrue(retVal.Any(x => x.Id.Equals("STK.PLC")));

			portfolioProvider.Verify(x => x.GetExistingBets(), Times.Once());
		}
		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 ConsistentChangeStockFilter(stockPriceProvider.Object, 5);

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

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

		}