Ejemplo n.º 1
0
        public void TestDefaultConstructor()
        {
            TradableProperty tradableProperty = new TradableProperty();

            Assert.AreEqual("Property", tradableProperty.getName());
            Assert.AreEqual(200m, tradableProperty.getPrice());
            Assert.AreEqual(50, tradableProperty.getRent());
            Assert.AreEqual("Property", tradableProperty.ToString().Substring(0, 8));
            Assert.IsTrue(tradableProperty.availableForPurchase());
        }
Ejemplo n.º 2
0
        public void TestLandon()
        {
            TradableProperty tradableProperty = new TradableProperty();
            Player           player           = new Player("Tom");

            Assert.AreEqual("Tom landed on Property. ", tradableProperty.landOn(ref player));
            tradableProperty.setOwner(ref player);
            Player player2 = new Player("Jerry", 10000.00m);

            Assert.AreEqual("Jerry landed on Property. Rent has been paid for Property of $50 to Tom.", tradableProperty.landOn(ref player2));
        }
Ejemplo n.º 3
0
        public void TestPayrent()
        {
            TradableProperty tradableProperty = new TradableProperty();
            Player           player           = new Player("Tom");
            Player           player2          = new Player("Jerry");

            tradableProperty.setOwner(ref player2);
            tradableProperty.payRent(ref player);
            Assert.AreEqual(1450, player.getBalance());
            Assert.AreEqual(1550, tradableProperty.getOwner().getBalance());
        }
Ejemplo n.º 4
0
        public void TestSetOwnerAndAvailable()
        {
            TradableProperty tradableProperty = new TradableProperty();
            Banker           banker           = Banker.access();

            tradableProperty.setOwner(banker);
            Assert.IsTrue(tradableProperty.availableForPurchase());
            Player player = new Player();

            tradableProperty.setOwner(ref player);
            Assert.IsFalse(tradableProperty.availableForPurchase());
        }
Ejemplo n.º 5
0
        public void TestMortgage()
        {
            TradableProperty p      = new TradableProperty();
            Player           player = new Player("Tom", 1000m);

            Assert.AreEqual(100m, p.getMortgageValue());
            p.mortgage(player);

            Assert.AreEqual(true, p.IsMortgaged);
            Assert.AreEqual(player.getBalance(), 1100);

            player.setBalance(100m);
            Assert.AreEqual(false, p.unmortgage(player));
            player.setBalance(1110m);
            Assert.AreEqual(true, p.unmortgage(player));
            Assert.AreEqual(player.getBalance(), 1000);
        }
Ejemplo n.º 6
0
        public void TestPurchase()
        {
            TradableProperty tradableProperty = new TradableProperty();
            Player           player           = new Player("Tom");

            tradableProperty.purchase(ref player);
            Assert.AreEqual(player.getBalance(), 1300);
            Assert.AreEqual(tradableProperty.getOwner().getName(), "Tom");
            Player player2 = new Player("Jerry");

            try
            {
                tradableProperty.purchase(ref player2);
            }catch (ApplicationException e)
            {
                Assert.AreEqual("System.ApplicationException", e.ToString().Substring(0, 27));
            }
        }
        public void TesttradeProperty()
        {
            Player player  = new Player("Tom");
            Player player1 = new Player("Jerry");

            TradableProperty property = new TradableProperty();

            property.setOwner(ref player);

            Assert.AreEqual("Tom", property.getOwner().getName());
            Assert.AreEqual(1500, property.getOwner().getBalance());
            Assert.AreEqual("Jerry", player1.getName());
            Assert.AreEqual(1500, player1.getBalance());

            player.tradeProperty(ref property, ref player1, property.getPrice());

            Assert.AreEqual("Jerry", property.getOwner().getName());
            Assert.AreEqual(1300, property.getOwner().getBalance());
            Assert.AreEqual("Tom", player.getName());
            Assert.AreEqual(1700, player.getBalance());
        }