public void Test_AddStockToPortfolio_SameStock() { string stockName = "IBM"; _stockExchange.ListStock(stockName, 5, 100m, DateTime.Now); string portfolioID = "P1"; _stockExchange.CreatePortfolio(portfolioID); _stockExchange.AddStockToPortfolio(portfolioID, stockName, 1); _stockExchange.AddStockToPortfolio(portfolioID, stockName, 2); Assert.True(_stockExchange.IsStockPartOfPortfolio(portfolioID, stockName)); Assert.AreEqual(1, _stockExchange.NumberOfStocksInPortfolio(portfolioID)); Assert.AreEqual(3, _stockExchange.NumberOfSharesOfStockInPortfolio(portfolioID, stockName)); }
public void Test_AddStockToPortfolio_Complicated() { // Dodaju se dionice u portfelj, onda se jedna obriše s burze i pokuša se dohvatiti u portfelju string dionica1 = "Dionica1"; _stockExchange.ListStock(dionica1, 1000000, 10m, DateTime.Now); string dionica2 = "Dionica2"; _stockExchange.ListStock(dionica2, 1000000, 10m, DateTime.Now); string portfelj1 = "portfelj1"; _stockExchange.CreatePortfolio(portfelj1); _stockExchange.AddStockToPortfolio(portfelj1, dionica1, 1); _stockExchange.AddStockToPortfolio(portfelj1, dionica2, 1); Assert.True(_stockExchange.IsStockPartOfPortfolio(portfelj1, dionica1)); Assert.True(_stockExchange.IsStockPartOfPortfolio(portfelj1, dionica2)); Assert.AreEqual(2, _stockExchange.NumberOfStocksInPortfolio(portfelj1)); _stockExchange.DelistStock(dionica1); Assert.False(_stockExchange.IsStockPartOfPortfolio(portfelj1, dionica1)); // treba baciti false, tak je Vanjak rekao (iako dionica ne postoji na burzi) }