Example #1
0
        public void CalculateNeededShares_ReturnsProperNumberOfShares()
        {
            var factory = new DividendCalculator
            {
                StockPrice         = 12.00M,
                DividendPercentage = 3.86M,
                DividendYield      = 13.90M
            };

            var result = factory.CalculateNeededShares();

            Assert.Equal(30, result);
        }
Example #2
0
        public void CalculateNeededSharesWithPeriod_ReturnsProperAmount()
        {
            var factory = new DividendCalculator
            {
                StockPrice         = 12.00M,
                DividendPercentage = 3.86M,
                DividendYield      = 15.00M
            };

            var result = factory.CalculateNeededShares(DividendPeriod.Quarterly);

            Assert.Equal(130, result);
        }
        private void ReverseCalculateDividend()
        {
            if (!CanReverseCalculate())
            {
                return;
            }

            var calculator = new DividendCalculator
            {
                StockPrice         = Convert.ToDecimal(RevStockPrice.Text),
                DividendPercentage = Convert.ToDecimal(RevPercent.Text),
                DividendYield      = Convert.ToDecimal(RevDesiredYield.Text)
            };
            var result = calculator.CalculateNeededShares(ReverseDividendCalcPeriod);

            LblRevSharedNeeded.Content = $"Shares Needed: {result}";
        }