Esempio n. 1
0
        public void Test_AbsorbHit_NoDamage()
        {
            _mockSettings.Setup(u => u.GetSetting <string>("Hostile")).Returns("blah Blah Blah!!!");

            var shipToTest = new Ship(FactionName.Klingon, "TestShip", _mockSector.Object, _mockMap.Object, _mockMap.Object.Game);

            Shields.For(shipToTest).Energy = 100;  //this is syntactic sugar for: ship.Subsystems.Single(s => s.Type == SubsystemType.Shields);

            Assert.AreEqual(100, Shields.For(shipToTest).Energy);

            _mockWrite.Setup(w => w.Line(It.IsAny <string>()));

            _mockMap.Object.Write = _mockWrite.Object;
            _mockSector.Setup(s => s.X).Returns(-2);
            _mockSector.Setup(s => s.Y).Returns(-3);

            var attacker = new Ship(FactionName.Klingon, "The attacking Ship", _mockSector.Object, _mockMap.Object, _mockMap.Object.Game);

            shipToTest.AbsorbHitFrom(attacker, 50);

            Assert.AreEqual(50, Shields.For(shipToTest).Energy);

            //Verifications of Output to User
            _mockSector.Verify(s => s.X, Times.Exactly(1));
            _mockSector.Verify(s => s.Y, Times.Exactly(1));

            _mockWrite.Verify(w => w.Line(It.IsAny <string>()), Times.Exactly(2));
            _mockWrite.Verify(w => w.Line("Your Ship has been hit by The attacking Ship at sector [-2,-3]."), Times.AtLeastOnce());
            _mockWrite.Verify(w => w.Line("No Damage."), Times.Once());
        }