Exemple #1
0
            public void A_guess_piece_is_Correct_when_it_is_the_same_as_its_corresponding_puzzle_piece()
            {
                var combination = new List <string> {
                    "One-White"
                };
                Puzzle puzzle = createPuzzle(combination);
                Guess  guess  = createGuess(combination);
                OverallFeedbackGenerator sut = new OverallFeedbackGenerator(puzzle);

                var actualFeedback = sut.Calculate(guess);

                Assert.AreEqual(1, actualFeedback.CorrectPieces);
                Assert.AreEqual(0, actualFeedback.MisplacedPieces);
            }
Exemple #2
0
            public void A_guess_piece_is_Misplaced_when_it_matches_a_puzzle_piece_but_their_places_do_not_match()
            {
                Puzzle puzzle = createPuzzle(new List <string> {
                    "One-White",
                    "Two-White"
                });
                Guess guess = createGuess(new List <string> {
                    "Two-White",
                    "One-White"
                });
                OverallFeedbackGenerator sut = new OverallFeedbackGenerator(puzzle);

                var actualFeedback = sut.Calculate(guess);

                Assert.AreEqual(0, actualFeedback.CorrectPieces);
                Assert.AreEqual(2, actualFeedback.MisplacedPieces);
            }
Exemple #3
0
        public void Calculate_throws_exception_if_guess_count_not_match_puzzle_count()
        {
            int puzzleCount                    = 4;
            FeedbackGenerator sut_1            = new FeedbackGenerator(new Puzzle(puzzleCount), new List <int>());
            var nonMatchingGuessCount_lower_1  = new Guess(puzzleCount - 1);
            var nonMatchingGuessCount_higher_1 = new Guess(puzzleCount + 1);

            Assert.Throws <InvalidOperationException>(() => sut_1.Calculate(nonMatchingGuessCount_lower_1));
            Assert.Throws <InvalidOperationException>(() => sut_1.Calculate(nonMatchingGuessCount_higher_1));

            OverallFeedbackGenerator sut_2     = new OverallFeedbackGenerator(new Puzzle(puzzleCount));
            var nonMatchingGuessCount_lower_2  = new Guess(puzzleCount - 1);
            var nonMatchingGuessCount_higher_2 = new Guess(puzzleCount + 1);

            Assert.Throws <InvalidOperationException>(() => sut_2.Calculate(nonMatchingGuessCount_lower_2));
            Assert.Throws <InvalidOperationException>(() => sut_2.Calculate(nonMatchingGuessCount_higher_2));
        }
Exemple #4
0
            public void A_guess_piece_can_produce_Similar_and_Misplaced_feedbacks_simultaneously()
            {
                Puzzle puzzle = createPuzzle(new List <string> {
                    "One-Black",
                    "None-None" //null piece
                });
                Guess guess = createGuess(new List <string> {
                    "One-White",
                    "One-Black"
                });
                OverallFeedbackGenerator sut = new OverallFeedbackGenerator(puzzle);

                var actualFeedback = sut.Calculate(guess);

                Assert.AreEqual(0, actualFeedback.CorrectPieces);
                Assert.AreEqual(1, actualFeedback.MisplacedPieces);
                Assert.AreEqual(1, actualFeedback.SimilarPieces);
            }