예제 #1
0
        public void Start_ShouldMarkTheGameAsStartedAndLoadTheBombsForPlayer1()
        {
            //Act
            var result = _game.Start();

            //Assert
            Assert.That(result.IsSuccess, Is.True, "A success result should be returned.");
            Assert.That(_game.IsStarted, Is.True, "Game is not marked as started.");
            var player1Mock = _player1Builder.BuildMock();

            player1Mock.Verify(p => p.ReloadBombs(), Times.Once, "Bombs for player 1 are not loaded.");
        }
예제 #2
0
        public void ShootAtOpponent_ShouldReturnAMisfireWhenNoBombsAreLoaded()
        {
            //Arrange
            GridCoordinate targetCoordinate = new GridCoordinateBuilder().Build();

            _player2Builder.WithBombsLoaded(false);
            Mock <IPlayer> player2Mock = _player2Builder.BuildMock();

            _game.Start();

            //Act
            ShotResult result = _game.ShootAtOpponent(_player2.Id, targetCoordinate);

            player2Mock.Verify(p => p.ShootAt(It.IsAny <IPlayer>(), It.IsAny <GridCoordinate>()), Times.Never,
                               "The ShootAt method of the player that shoots should not be called when no bombs are loaded.");
            Assert.That(result.ShotFired, Is.False, "The ShotResult should indicate that no shot is fired.");
            Assert.That(result.MisfireReason, Is.Not.Empty, "The ShotResult should contain a misfire reason.");
        }