Exemplo n.º 1
0
        public void BaseStockConstructorTest()
        {
            string    name   = baseStockTestName;
            BaseStock target = new BaseStock(name);

            Assert.IsTrue(Directory.Exists(appDataPath + "\\" + baseStockTestName), "OOPS! Stock directory does not exist.");
        }
Exemplo n.º 2
0
        public void DeleteStockTest()
        {
            string    name   = baseStockTestName;
            BaseStock target = new BaseStock(name);

            target.DeleteStock();
            Assert.IsFalse(Directory.Exists(appDataPath + "\\" + baseStockTestName), "SHIT! Deleted stock directory still exists.");
        }
Exemplo n.º 3
0
        public void GetChildStockRefTest()
        {
            string    name   = baseStockTestName;
            BaseStock target = new BaseStock(name);
            string    name1  = "Child stock";
            BaseStock actual;

            actual = target.GetChildStockRef(name1);
            Assert.IsTrue(actual != null, "DOH! Child stock is null.");
            Assert.IsTrue(Directory.Exists(appDataPath + "\\" + baseStockTestName + "\\" + name1), "GOSH! Child stock directory was not created.");
        }
Exemplo n.º 4
0
        public void GetChildFileTest1()
        {
            string     name   = baseStockTestName;
            BaseStock  target = new BaseStock(name);
            string     name1  = "File";
            FileStream actual;

            actual = target.GetChildFile(name1);
            Assert.AreEqual(appDataPath + "\\" + baseStockTestName + "\\" + name1, actual.Name, "DAMN! Returned FileStream has different name than it should.");
            actual.Close();
        }
Exemplo n.º 5
0
        public void isStockReusedTest1()
        {
            string    name  = baseStockTestName;
            BaseStock stock = new BaseStock(name);

            PrivateObject      param0 = new PrivateObject(stock);
            BaseStock_Accessor target = new BaseStock_Accessor(param0);
            bool expected             = false;
            bool actual;

            target.isStockReused = expected;
            actual = target.isStockReused;
            Assert.AreEqual(expected, actual, "OH NO! Not reused stock is marked as reused.");
        }
Exemplo n.º 6
0
        public void GetChildFileTest()
        {
            string    name   = baseStockTestName;
            BaseStock target = new BaseStock(name);
            string    name1  = "File";

            BaseStock.Initializer func = delegate(FileStream s) { ++initializerFuncCounter; };
            FileStream            actual;

            actual = target.GetChildFile(name1, func);
            Assert.AreEqual(actual.Name, appDataPath + "\\" + baseStockTestName + "\\" + name1, "DAMN! Returned FileStream has different name than it should.");
            Assert.IsTrue(initializerFuncCounter == 1, "DAMN! Initializer functions was not called.");
            actual.Close();
        }
Exemplo n.º 7
0
        public void DeleteChildFileTest()
        {
            string    name   = baseStockTestName;
            BaseStock target = new BaseStock(name);
            string    name1  = "File";

            BaseStock.Initializer func = delegate(FileStream s) { ++initializerFuncCounter; };
            FileStream            actual;

            actual = target.GetChildFile(name1);
            actual.Close();
            target.DeleteChildFile(name1);
            Assert.IsFalse(File.Exists(appDataPath + "\\" + baseStockTestName + "\\" + name1), "GOSH! Child file exist after deletion.");
        }
Exemplo n.º 8
0
        public void Test_ExchangeFindStockException()
        {
            string stock         = "GIN";
            double lastDividend  = 8;
            double fixedDividend = 2;
            double parValue      = 100;
            double stockPrice    = 25;

            GBCE exchange = new GBCE();

            exchange.addPreferredStock(stock, lastDividend, fixedDividend, parValue, stockPrice);

            stock = "POP";

            BaseStock selectedStock = exchange.GetStock(stock);
        }
Exemplo n.º 9
0
        public void isRemovedTest()
        {
            string    name  = baseStockTestName;
            BaseStock stock = new BaseStock(name);

            stock.DeleteStock();

            PrivateObject      param0 = new PrivateObject(stock);
            BaseStock_Accessor target = new BaseStock_Accessor(param0);
            bool expected             = true;
            bool actual;

            target.isRemoved = expected;
            actual           = target.isRemoved;
            Assert.AreEqual(expected, actual, "EWW! Removed object is not marked as removed.");
        }
Exemplo n.º 10
0
        public void Test_ExchangeFindStock()
        {
            string stock         = "GIN";
            double lastDividend  = 8;
            double fixedDividend = 2;
            double parValue      = 100;
            double stockPrice    = 25;

            GBCE exchange = new GBCE();

            exchange.addPreferredStock(stock, lastDividend, fixedDividend, parValue, stockPrice);

            stock        = "POP";
            lastDividend = 4;
            stockPrice   = 50;

            exchange.addCommonStock(stock, lastDividend, stockPrice);

            Assert.AreEqual(2, exchange.stocks.Count); //Verify there are two stocks in the exchange

            BaseStock selectedStock = exchange.GetStock(stock);

            Assert.AreEqual(50, selectedStock.stockPrice); //Verify it has the correct stock price
        }