예제 #1
0
        public void Pay_WhenTheObjectPassedIsNull_ShouldThrowNullReferenceException()
        {
            // Arrange
            var someUnit = new Unit(1, "Mimi");

            // Act&Assert
            Assert.Throws<NullReferenceException>(() => someUnit.Pay(null));
        }
예제 #2
0
        public void Pay_ShouldDecreaseResourcesAmountOfTheOwnerByCostAmount()
        {
            // Arrange
            var mimi = new Unit(1, "Mimi");
            mimi.Resources.BronzeCoins = 25;
            mimi.Resources.SilverCoins = 50;
            mimi.Resources.GoldCoins = 100;

            var cost = new Resources(5, 7, 60);

            // Act
            mimi.Pay(cost);

            // Assert
            Assert.AreEqual(20, mimi.Resources.BronzeCoins);
            Assert.AreEqual(43, mimi.Resources.SilverCoins);
            Assert.AreEqual(40, mimi.Resources.GoldCoins);
        }
예제 #3
0
        public void Pay_ShouldReturnResourceObjectWithTheAmountOfResourcesInTheCostObject()
        {
            // Arrange
            var mimi = new Unit(1, "Mimi");
            mimi.Resources.BronzeCoins = 25;
            mimi.Resources.SilverCoins = 50;
            mimi.Resources.GoldCoins = 100;

            var cost = new Resources(5, 7, 60);

            // Act
            var returnObject = mimi.Pay(cost);

            // Assert
            Assert.IsInstanceOf<Resources>(returnObject);
            Assert.AreEqual(cost.BronzeCoins, returnObject.BronzeCoins);
            Assert.AreEqual(cost.SilverCoins, returnObject.SilverCoins);
            Assert.AreEqual(cost.GoldCoins, returnObject.GoldCoins);
        }