예제 #1
0
        public void InitStock()
        {
            IStockFactory stockFactory = new StockFactory();

            bondStock = stockFactory.CreateStock(AssetType.Bond, price, quantity, 0);
            bondStock.TotalMarketValue = totalFundValue;
            equityStock = stockFactory.CreateStock(AssetType.Equity, price, quantity, 0);
            equityStock.TotalMarketValue = totalFundValue;
        }
예제 #2
0
        public void CreateEquityTest()
        {
            var factory = new StockFactory();

            var stock = factory.CreateStock(StockType.Bond, "Equity1", 1500, 500);

            Assert.AreEqual(stock.Price, 1500);
            Assert.AreEqual(stock.Quantity, 500);
            Assert.AreEqual(stock.MarketValue, 1500 * 500);
            Assert.AreEqual(stock.MarketValue, 1500 * 500);
        }
예제 #3
0
        public void CreateBondTest()
        {
            StockFactory stockFactory = new StockFactory();
            AssetType    type         = AssetType.Bond;
            decimal      price        = 20;
            int          quantity     = 1;
            int          occurence    = 0;
            Stock        s            = stockFactory.CreateStock(type, price, quantity, occurence);

            Assert.AreEqual(s.AssetType, type);
            Assert.AreEqual(s.Price, price);
            Assert.AreEqual(s.Quantity, quantity);
            Assert.AreEqual(s.StockName, type.ToString() + (occurence + 1).ToString());
            Assert.IsTrue(s.GetType() == typeof(Bond));
        }