/// <summary>
        /// Cache Investment Term
        /// </summary>
        void CacheInvestmentTerm()
        {
            InvestmentTerm investTerm = new InvestmentTerm()
            {
                SortOrder   = 1,
                Description = "Short Term",
            };

            //Save object
            Save <InvestmentTerm>(investTerm, transaction);

            investTerm = new InvestmentTerm()
            {
                SortOrder   = 2,
                Description = "Medium Term",
            };

            //Save object
            Save <InvestmentTerm>(investTerm, transaction);

            investTerm = new InvestmentTerm()
            {
                SortOrder   = 3,
                Description = "Long Term",
            };

            //Save object
            Save <InvestmentTerm>(investTerm, transaction);
        }
        public void GetTerm_GreaterThan365_expectLong()
        {
            // Arrange
            decimal           originalSharePrice  = 125.44M;
            decimal           currentPrice        = 99.33M;
            int               numShares           = 44;
            DateTime          currentDate         = new DateTime(2020, 5, 12);
            DateTime          purchaseDate        = new DateTime(2018, 1, 15);
            InvestmentProduct investmentProduct   = new InvestmentProduct(1, "ABC", currentPrice, currentDate);
            TradeTransaction  purchaseTransaction = new TradeTransaction(_nLogger, 1, TransactionType.Buy, purchaseDate, numShares, originalSharePrice);
            UserInvestment    userInvestment      = new UserInvestment(_nLogger, investmentProduct, purchaseTransaction);

            // Act
            InvestmentTerm actualTerm = userInvestment.GetTerm();

            // Assert
            Assert.AreEqual(InvestmentTerm.Long, actualTerm);
        }
Exemple #3
0
        public InvestmentTerm GetTerm()
        {
            InvestmentTerm term = InvestmentTerm.Short;

            try
            {
                TimeSpan timeSpanDiff = _investmentProduct.CurrentPriceDate.Subtract(_purchaseTransaction.TradeDate);
                int      days         = timeSpanDiff.Days;
                if (days > 365)                 // for now, ignoring leap year
                {
                    term = InvestmentTerm.Long;
                }
            }
            catch (Exception ex)
            {
                _nLogger.Error(ex, $"Exception getting term");
            }

            return(term);
        }