Exemplo n.º 1
0
        public void GetDividendYieldForCommonStockTest()
        {
            var          stock        = TestData.GetTestCommonStock();
            var          stockService = new StocksService();
            const double marketPrice  = 100;
            const double lastDividend = 2.54;

            const double expectedValue = lastDividend / marketPrice;
            var          actualValue   = stockService.GetDividendYield(stock, marketPrice);

            Assert.AreEqual(expectedValue, actualValue);
        }
        static void GivenMarketPriceAsInputCalculateDividendYield(double marketPrice)
        {
            foreach (var stock in _stockService._stockRepository.GetAll())
            {
                double DividendYield = _stockService.GetDividendYield(stock.Symbol, marketPrice);

                Console.WriteLine("------");
                Console.WriteLine(stock + " " + "Dividend Yield is: " + DividendYield);
            }
            Console.WriteLine("Completed Calculating Dividend Yield");
            Console.WriteLine("------------------------------------");
            Console.WriteLine();
        }
Exemplo n.º 3
0
        public void GetDividendYieldForPreferredStockTest()
        {
            var stockService = new StocksService();

            var          stock         = TestData.GetTestPreferredStock();
            const double marketPrice   = 313;
            const double fixedDividend = 0.03;
            const double parValue      = 100;

            const double expectedValue = (fixedDividend * parValue) / marketPrice;

            var actualValue = stockService.GetDividendYield(stock, marketPrice);

            Assert.AreEqual(expectedValue, actualValue);
        }