Inheritance: GameAction
Beispiel #1
0
        public void PickaxeMakesDamageWall0(float damage)
        {
            // Arrange
            Mock<GameActor> actorMock = new Mock<GameActor>();
            UsePickaxe pickaxe = new UsePickaxe(actorMock.Object) { Damage = damage };
            Mock<IAtlas> atlasMock = new Mock<IAtlas>();
            GameActor pickaxedWall = null;
            atlasMock.Setup(x => x.ReplaceWith(It.IsAny<GameActorPosition>(), It.IsAny<GameActor>())).
                Callback((GameActorPosition original, GameActor replacement) => pickaxedWall = replacement);

            // Act
            m_wall.ApplyGameAction(atlasMock.Object, pickaxe, new Vector2(), m_tilesetTable);

            // Assert
            if (damage >= 1)
                Assert.IsType(typeof(DestroyedWall), pickaxedWall);
            else if (damage > 0)
            {
                Assert.IsType(typeof(DamagedWall), pickaxedWall);
                DamagedWall damagedWall = (DamagedWall)pickaxedWall;
                Assert.True(damagedWall.Health >= 1.0f - damage);
            }
            else
                Assert.Equal(null, pickaxedWall);

        }
Beispiel #2
0
        public void PickaxeMakesDestroyedWallFromDamagedWall(float damage)
        {
            // Arrange
            Mock<GameActor> actorMock = new Mock<GameActor>();
            Mock<IAtlas> atlasMock = new Mock<IAtlas>();
            GameActor pickaxedWall = null;
            atlasMock.Setup(x => x.ReplaceWith(It.IsAny<GameActorPosition>(), It.IsAny<GameActor>())).
                Callback((GameActorPosition original, GameActor replacement) => pickaxedWall = replacement);

            UsePickaxe pickaxe = new UsePickaxe(actorMock.Object) { Damage = damage };
            float initialDamage = 0.5f;
            DamagedWall damagedWall = new DamagedWall(initialDamage, m_tilesetTable, Vector2I.Zero);

            // Act
            damagedWall.ApplyGameAction(atlasMock.Object, pickaxe, new Vector2(), m_tilesetTable);

            // Assert
            if (damage + initialDamage >= 1)
                Assert.IsType(typeof(DestroyedWall), pickaxedWall);
            else
                Assert.Equal(null, pickaxedWall);
        }