Exemple #1
0
        public void BattleshipsGameStart_WhenStartingGame_AWinnerIsFoundAndSet()
        {
            //arrange
            var mockSetting = SetupSettings(10);
            var mockInput   = new Mock <IInput>();

            mockInput.Setup(x => x.AskUserForShipPlacementCoordinates())
            .Returns(() => GenerateMockSetUpShipPlacementCoordinates());
            mockInput.Setup(x => x.AskUserForAttackingCoordinates())
            .Returns(() => GenerateMockSetUpAttackingCoordinates());

            var battleships = new Battleships(mockSetting, mockInput.Object);

            const string mockPlayerName   = "Chris";
            const string mockOpponentName = "John";

            battleships.CreatePlayer(mockPlayerName);
            battleships.CreatePlayer(mockOpponentName);

            //act
            var player   = battleships.GetPlayer(mockPlayerName);
            var opponent = battleships.GetPlayer(mockOpponentName);

            player.SetShips();
            opponent.SetShips();
            battleships.StartGame();

            //assert
            battleships.GetWinner().Should().NotBe(null);
            battleships.GetWinner().Should().BeOneOf("Chris", "John", "Draw");
        }