コード例 #1
0
ファイル: TestsWordGame.cs プロジェクト: JorisAlbers/slingo
        public void Reject_WordAlmostGuessed_StateSetToSwitchTeam()
        {
            var puzzleEntry = new WordPuzzleEntry(new[]
            {
                new WordPuzzleLetterEntry('a', LetterState.CorrectLocation),
                new WordPuzzleLetterEntry('a', LetterState.CorrectLocation),
                new WordPuzzleLetterEntry('a', LetterState.CorrectLocation),
                new WordPuzzleLetterEntry('a', LetterState.CorrectLocation),
                new WordPuzzleLetterEntry('b', LetterState.IncorrectLocation),
            });

            var wordPuzzleMock = new Mock <WordPuzzle>("aaaaa");

            wordPuzzleMock.Setup(x => x.Solve(It.IsAny <string>())).Returns(puzzleEntry);


            WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0);

            wordGame.Solve("aaaab");
            wordGame.Reject();

            Assert.AreEqual(1, wordGame.ActiveTeamIndex);
            Assert.AreEqual(1, wordGame.AttemptIndex);
            Assert.AreEqual(WordGameState.SwitchTeam, wordGame.State.State);
            Assert.IsTrue((wordGame.State.Flags & SwitchTeamFlags.ClearRow) == SwitchTeamFlags.ClearRow);
        }
コード例 #2
0
 /// <summary>
 /// Reject the word that was previously set
 /// </summary>
 public async Task <WordGameStateInfo> RejectWord()
 {
     _audioPlaybackEngine.PlaySound(_rejectSound);
     _wordGame.Reject();
     _state.SwitchActiveTeam();
     return(_wordGame.State);
 }
コード例 #3
0
ファイル: TestsWordGame.cs プロジェクト: JorisAlbers/slingo
        public void Reject_KeepsIndexButSwitchesTeam()
        {
            var puzzleEntry = new WordPuzzleEntry(Enumerable.Repeat(new WordPuzzleLetterEntry('a', LetterState.IncorrectLocation), 5).ToArray());


            var wordPuzzleMock = new Mock <WordPuzzle>("aaaa");

            wordPuzzleMock.Setup(x => x.Solve(It.IsAny <string>())).Returns(puzzleEntry);


            WordGame wordGame = new WordGame(wordPuzzleMock.Object, 0);

            wordGame.Reject();

            Assert.AreEqual(1, wordGame.ActiveTeamIndex);
            Assert.AreEqual(0, wordGame.AttemptIndex);
            Assert.AreEqual(WordGameState.SwitchTeam, wordGame.State.State);
            Assert.IsTrue((wordGame.State.Flags & SwitchTeamFlags.ClearRow) == SwitchTeamFlags.ClearRow);
            Assert.IsTrue((wordGame.State.Flags & SwitchTeamFlags.AddBonusLetter) == SwitchTeamFlags.AddBonusLetter);
        }