Exemple #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());
        }
        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());
        }