コード例 #1
0
 private ISpaceShip SpaceShipWithTwoFunctionalWeaponStubs()
 {
     var spaceship = new SpaceShip(2, 0);
     spaceship.Equip(new FunctionalWeaponStub());
     spaceship.Equip(new FunctionalWeaponStub());
     return spaceship;
 }
コード例 #2
0
        private static SpaceShip SpaceShipWithTwoFunctionalWeaponStubs()
        {
            var spaceShip = new SpaceShip(2, 0);

            spaceShip.Equip(new FunctionalWeaponStub());
            spaceShip.Equip(new FunctionalWeaponStub());
            return(spaceShip);
        }
コード例 #3
0
        public void NoWeaponSlotsAvailable_AfterWeaponIsEquiped()
        {
            // Arrange
            SpaceShip spaceShip = SpaceShipWithSingleWeaponSlot();
            IWeapon   weapon    = new DummyWeapon();

            // Act
            spaceShip.Equip(weapon);
            // Assert
            var noWeaponSlotsAvailable = spaceShip.AvailableWeaponSlots == 0;

            Assert.That(noWeaponSlotsAvailable);
        }
コード例 #4
0
        public void NoWeaponSlotsAvailable_AfterWeaponIsEquiped2()
        {
            // Arrange.
            SpaceShip spaceShip = SpaceShipWithSingleWeaponSlot();
            IWeapon   weapon    = NSubstitute.Substitute.For <IWeapon>();

            // Act.
            spaceShip.Equip(weapon);

            // Assert.
            bool noWeaponSlotsAvailable = 0 == spaceShip.AvailableWeaponSlots;

            Assert.True(noWeaponSlotsAvailable);
        }
コード例 #5
0
        public void EachWeaponShoots_WhenSpaceShipShootIsCalled()
        {
            // Arrange
            var weapon1 = Substitute.For<IWeapon>();
            var weapon2 = Substitute.For<IWeapon>();

            var ship = new SpaceShip(2, 0);
            ship.Equip(weapon1);
            ship.Equip(weapon2);

            // Act
            ship.Shoot();

            // Assert
            weapon1.Received(1).Shoot();
            weapon2.Received(1).Shoot();
        }
コード例 #6
0
        public void EachWeaponShoots_WhenSpaceShipShootIsCalled()
        {
            // Arrange.
            var weapon1 = Substitute.For <IWeapon>();
            var weapon2 = Substitute.For <IWeapon>();

            var spaceShip = new SpaceShip(2, 0);

            spaceShip.Equip(weapon1);
            spaceShip.Equip(weapon2);

            // Act.
            spaceShip.Shoot();

            // Assert.
            weapon1.Received(1).Shoot();
            weapon2.Received(1).Shoot();
        }
コード例 #7
0
        public void EachWeaponGetsReloaded_AfterItIsShot()
        {
            // Arrange
            var weapon1 = Substitute.For<IWeapon>();
            var weapon2 = Substitute.For<IWeapon>();

            var ship = new SpaceShip(2, 0);
            ship.Equip(weapon1);
            ship.Equip(weapon2);

            // Act
            ship.Shoot();

            // Assert
            Received.InOrder(() =>
                {
                    weapon1.Shoot();
                    weapon2.Shoot();
                    weapon1.Reload();
                    weapon2.Reload();
                }
            );
        }
コード例 #8
0
        public void EachWeaponGetsReloaded_AfterItIsShot()
        {
            // Arrange
            var weapon1 = Substitute.For <IWeapon>();
            var weapon2 = Substitute.For <IWeapon>();

            var ship = new SpaceShip(2, 0);

            ship.Equip(weapon1);
            ship.Equip(weapon2);

            // Act
            ship.Shoot();

            // Assert
            Received.InOrder(() =>
            {
                weapon1.Shoot();
                weapon2.Shoot();
                weapon1.Reload();
                weapon2.Reload();
            }
                             );
        }
コード例 #9
0
        private static SpaceShip SpaceShipWithSingleWeaponSlot()
        {
            SpaceShip spaceShip = new SpaceShip(1, 0);

            return(spaceShip);
        }
コード例 #10
0
 private static SpaceShip SpaceShipWithSingleWeaponSlot()
 {
     SpaceShip spaceShip = new SpaceShip(1, 0);
     return spaceShip;
 }