Beispiel #1
0
        public void Test_SetStockPrice_NewPrice()
        {
            string stockName = "IBM";
            decimal oldPrice = 10m;
            _stockExchange.ListStock(stockName, 1000000, oldPrice, new DateTime(2012, 1, 10, 15, 22, 00));
            decimal newPrice = 20m;
            _stockExchange.SetStockPrice(stockName, new DateTime(2012, 1, 10, 15, 40, 00), newPrice);

            Assert.AreEqual(newPrice, _stockExchange.GetStockPrice(stockName, new DateTime(2012, 1, 10, 15, 50, 0, 0)));
        }
Beispiel #2
0
        public void Test_GetIndexValue_AverageAfterPriceChange()
        {
            // Provjera izračuna AverageIndexa nakon promijene cijene

            string dionica1 = "Dionica1";

            _stockExchange.ListStock(dionica1, 1000, 100m, new DateTime(2014, 1, 1, 0, 0, 0));
            string dionica2 = "Dionica2";

            _stockExchange.ListStock(dionica2, 1000, 200m, new DateTime(2014, 1, 1, 0, 0, 0));

            string indeks1 = "indeks1";

            _stockExchange.CreateIndex(indeks1, IndexTypes.AVERAGE);

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

            Assert.AreEqual(150, _stockExchange.GetIndexValue(indeks1, new DateTime(2014, 1, 2, 0, 0, 0)));

            _stockExchange.SetStockPrice(dionica2, new DateTime(2014, 1, 3, 0, 0, 0), 300m);

            Assert.AreEqual(200, _stockExchange.GetIndexValue(indeks1, new DateTime(2014, 1, 4, 0, 0, 0)));
        }