Example #1
0
        public void Test_AddStockToIndex_Complicated()
        {
            // Dodaju se dionice u index, onda se jedna obriše s burze i pokuša se dohvatiti u indeksu

            string dionica1 = "Dionica1";

            _stockExchange.ListStock(dionica1, 1000000, 10m, DateTime.Now);
            string dionica2 = "Dionica2";

            _stockExchange.ListStock(dionica2, 1000000, 10m, DateTime.Now);

            string indeks1 = "indeks1";

            _stockExchange.CreateIndex(indeks1, IndexTypes.WEIGHTED);

            _stockExchange.AddStockToIndex(indeks1, dionica1);
            _stockExchange.AddStockToIndex(indeks1, dionica2);

            Assert.True(_stockExchange.IsStockPartOfIndex(indeks1, dionica1));
            Assert.True(_stockExchange.IsStockPartOfIndex(indeks1, dionica2));
            Assert.AreEqual(2, _stockExchange.NumberOfStocksInIndex(indeks1));

            _stockExchange.DelistStock(dionica1);

            _stockExchange.RemoveStockFromIndex(indeks1, dionica1);             // treba baciti exception
        }
Example #2
0
        public void Test_AddStockToIndex_Simple()
        {
            string firstStockName = "IBM";
            _stockExchange.ListStock(firstStockName, 5, 100m, DateTime.Now);
            string secondStockName = "MSFT";
            _stockExchange.ListStock(secondStockName, 5, 200m, DateTime.Now);
            string thirdStockName = "GOOG";
            _stockExchange.ListStock(thirdStockName, 1, 300m, DateTime.Now);

            string indexName = "DOW JONES";
            _stockExchange.CreateIndex(indexName, IndexTypes.WEIGHTED);

            _stockExchange.AddStockToIndex(indexName, firstStockName);
            _stockExchange.AddStockToIndex(indexName, secondStockName);
            _stockExchange.AddStockToIndex(indexName, thirdStockName);

            Assert.True(_stockExchange.IsStockPartOfIndex(indexName, firstStockName));
            Assert.True(_stockExchange.IsStockPartOfIndex(indexName, secondStockName));
            Assert.True(_stockExchange.IsStockPartOfIndex(indexName, thirdStockName));
            Assert.AreEqual(3, _stockExchange.NumberOfStocksInIndex(indexName));
        }