예제 #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.");
        }
예제 #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.");
        }
예제 #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.");
        }
예제 #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();
        }
예제 #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.");
        }
예제 #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();
        }
예제 #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.");
        }
예제 #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);
        }
예제 #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.");
        }
예제 #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
        }