Esempio n. 1
0
        public void Test_GetIndexValue_Weighted()
        {
            string firstStockName = "IBM";
            _stockExchange.ListStock(firstStockName, 1, 100m, new DateTime(2012, 1, 11, 14, 10, 00, 00));
            string secondStockName = "MSFT";
            _stockExchange.ListStock(secondStockName, 2, 200m, new DateTime(2012, 1, 11, 14, 10, 00, 00));

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

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

            Assert.AreEqual(180m, _stockExchange.GetIndexValue(indexName, new DateTime(2012, 1, 11, 14, 11, 00, 00)));
        }
Esempio n. 2
0
        public void Test_GetIndexValue_Average()
        {
            // Provjera izračuna AverageIndexa

            string dionica1 = "Dionica1";

            _stockExchange.ListStock(dionica1, 1000, 100m, DateTime.Now);
            System.Threading.Thread.Sleep(10);

            string dionica2 = "Dionica2";

            _stockExchange.ListStock(dionica2, 1000, 200m, DateTime.Now);
            System.Threading.Thread.Sleep(10);

            string indeks1 = "indeks1";

            _stockExchange.CreateIndex(indeks1, IndexTypes.AVERAGE);

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

            Assert.AreEqual(150, _stockExchange.GetIndexValue(indeks1, DateTime.Now));
        }