Exemplo n.º 1
0
 public void Test_CreateIndex_Simple()
 {
     string firstIndexName = "DOW JONES";
     _stockExchange.CreateIndex(firstIndexName, IndexTypes.AVERAGE);
     string secondIndexName = "S&P";
     _stockExchange.CreateIndex(secondIndexName, IndexTypes.WEIGHTED);
     Assert.AreEqual(2, _stockExchange.NumberOfIndices());
     Assert.True(_stockExchange.IndexExists(firstIndexName));
     Assert.True(_stockExchange.IndexExists(secondIndexName));
     Assert.False(_stockExchange.IndexExists("AB"));
 }
Exemplo n.º 2
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
        }