示例#1
0
        public void CalulcateDividendYieldWithPeriod_ReturnsProperAmount()
        {
            var factory = new DividendCalculator
            {
                StockPrice         = 12.00M,
                NumberOfShares     = 30,
                DividendPercentage = 3.86M
            };
            var result = factory.CalculateDividendYield(DividendPeriod.Quarterly);

            Assert.Equal(3.48M, result);
        }
示例#2
0
        public void CalculateDividendYield_ReturnsProperAmount()
        {
            var factory = new DividendCalculator
            {
                StockPrice         = 12.00M,
                NumberOfShares     = 30,
                DividendPercentage = 3.86M
            };
            var result = factory.CalculateDividendYield();

            Assert.Equal(13.90M, result);
        }
示例#3
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);
        }
示例#4
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);
        }
        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}";
        }
        private void CalculateDividendYield()
        {
            if (!CanCalculateYield())
            {
                return;
            }

            var calculate = new DividendCalculator
            {
                StockPrice         = Convert.ToDecimal(DivStockPrice.Text),
                NumberOfShares     = Convert.ToInt32(DivNumberOfSharesOwned.Text),
                DividendPercentage = Convert.ToDecimal(DivPercent.Text)
            };

            var result = calculate.CalculateDividendYield(DividendCalcPeriod);

            LblDivYield.Content = $"Total Yield: ${result:.##}";
        }