예제 #1
0
        public async Task TestDatabaseCallAsync()
        {
            //Set up the correct results to match open what we should get.

            var id                = 1;
            var investmentName    = "PNC";
            var numberOfShares    = 500;
            var costBasisPerShare = 125.75;      //Price we paid per share when we bought the stock
            var currentPrice      = 137.43;
            var currentValue      = 68715;       //Number of shares * current price
            var shortOrLongTerm   = "Long Term"; //Should be long term since it over 1 year
            var gainOrLoss        = 5840;        //currentValue - (number of shares * costBasisPerShare)

            //Load the sample database and return the context
            //Get the results back from the database call
            InvestmentOutput result = await InvestmentDatabaseCalls.GetInvestmentDetails(LoadSampleDatabaseAndReturnContext(), id);

            Assert.AreEqual(result.Id, id);
            Assert.AreEqual(result.Name, investmentName);
            Assert.AreEqual(result.NumberOfShares, numberOfShares);
            Assert.AreEqual(result.CostBasisPerShare, costBasisPerShare);
            Assert.AreEqual(result.CurrentPrice, currentPrice);
            Assert.AreEqual(result.CurrentValue, currentValue);
            Assert.AreEqual(result.Term, shortOrLongTerm);
            Assert.AreEqual(result.GainOrLoss, gainOrLoss);
        }
 public async Task <InvestmentOutput> ReturnInvestmentDetailedView(int id)
 {
     //Call the database routine.
     return(await InvestmentDatabaseCalls.GetInvestmentDetails(_context, id));
 }