예제 #1
0
        public void GetCostBasisPerShare_TypicalValues_ExpectCorrectAnswer()
        {
            // Arrange
            decimal           originalSharePrice  = 125.44M;
            int               numShares           = 44;
            InvestmentProduct investmentProduct   = new InvestmentProduct(1, "ABC", 1223.67M, DateTime.Now);
            TradeTransaction  purchaseTransaction = new TradeTransaction(_nLogger, 1, TransactionType.Buy, DateTime.Now, numShares, originalSharePrice);
            UserInvestment    userInvestment      = new UserInvestment(_nLogger, investmentProduct, purchaseTransaction);

            // Act
            decimal basisCost = userInvestment.GetCostPerBasisShare();

            // Assert
            Assert.AreEqual(originalSharePrice * numShares, basisCost);
        }
예제 #2
0
        private void DisplayInvestmentDetails(UserInvestment selectedInvestment)
        {
            try
            {
                InvestmentProduct product     = selectedInvestment.GetInvestmentProduct();
                TradeTransaction  transaction = selectedInvestment.GetPurchaseTransaction();
                investmentName.InnerText    = product.Name;
                numShares.InnerText         = transaction.NumShares.ToString();;
                costBasisPerShare.InnerText = selectedInvestment.GetCostPerBasisShare().ToString("C3");
                currentValue.InnerText      = selectedInvestment.GetCurrentValue().ToString("C3");
                currentPrice.InnerText      = product.CurrentPrice.ToString("C3");
                term.InnerText          = selectedInvestment.GetTerm().ToString();
                totalGainLoss.InnerText = selectedInvestment.GetTotalGainLoss().ToString("C3");

                _nLogger.Info($"Displaying details for {product.Name}");
            }
            catch (Exception ex)
            {
                errorLabel.InnerText = "Error displaying investment details.  Please try again later";
                _nLogger.Error(ex, "Exception displaying investment details");
            }
        }