public void Test_RemoveStockFromPortfolio_NumOfShares() { string firstStockName = "IBM"; _stockExchange.ListStock(firstStockName, 5, 100m, DateTime.Now); string secondStockName = "MSFT"; _stockExchange.ListStock(secondStockName, 5, 200m, DateTime.Now); string portfolioID = "P1"; _stockExchange.CreatePortfolio(portfolioID); _stockExchange.AddStockToPortfolio(portfolioID, firstStockName, 4); _stockExchange.AddStockToPortfolio(portfolioID, secondStockName, 1); _stockExchange.RemoveStockFromPortfolio(portfolioID, firstStockName, 2); Assert.True(_stockExchange.IsStockPartOfPortfolio(portfolioID, firstStockName)); Assert.True(_stockExchange.IsStockPartOfPortfolio(portfolioID, secondStockName)); Assert.AreEqual(2, _stockExchange.NumberOfStocksInPortfolio(portfolioID)); Assert.AreEqual(2, _stockExchange.NumberOfSharesOfStockInPortfolio(portfolioID, firstStockName)); Assert.AreEqual(1, _stockExchange.NumberOfSharesOfStockInPortfolio(portfolioID, secondStockName)); }
public void Test_GetPortfolioValue_AfterRemovingStock() { // Provjera izračuna vrijednosta portfelja nakon brisanja dionice iz portfolia string dionica1 = "Dionica1"; _stockExchange.ListStock(dionica1, 1000, 100m, new DateTime(2014, 1, 1, 0, 0, 0, 0)); // 1.1.2014. 0:00 100kn string dionica2 = "Dionica2"; _stockExchange.ListStock(dionica2, 1000, 100m, new DateTime(2014, 1, 1, 0, 0, 0, 0)); // 1.1.2014. 0:00 100kn string portfolio1 = "portfolio1"; _stockExchange.CreatePortfolio(portfolio1); _stockExchange.AddStockToPortfolio(portfolio1, dionica1, 10); _stockExchange.AddStockToPortfolio(portfolio1, dionica2, 10); Assert.AreEqual(2000, _stockExchange.GetPortfolioValue(portfolio1, new DateTime(2014, 3, 1, 0, 0, 0, 0))); // 1.3.2014. 0:00 PROVJERA _stockExchange.RemoveStockFromPortfolio(portfolio1, dionica2); Assert.AreEqual(1000, _stockExchange.GetPortfolioValue(portfolio1, new DateTime(2014, 3, 1, 0, 0, 0, 0))); // 1.3.2014. 0:00 }