Example #1
0
        public void CreateHintBasedOnPlayerSolutionShould_CreateHintWith4KeyPegs_BasedOnPlayerSolution()
        {
            var secretSolutionGenerator = new SecretSolutionGenerator();
            var mastermind = new Mastermind(secretSolutionGenerator);
            var peg1       = new Peg(Colour.Red);
            var peg2       = new Peg(Colour.Blue);
            var peg3       = new Peg(Colour.Green);
            var peg4       = new Peg(Colour.Orange);
            var solution   = new[] { peg1, peg2, peg3, peg4 };
            var hint       = mastermind.CreateHintBasedOnPlayerSolution(solution);

            Assert.Equal(4, hint.Length);
        }
Example #2
0
        public void CreateHintBasedOnPlayerSolutionShould_CreateCorrectHint2Black_BasedOnPlayerSolution()
        {
            var secretSolutionGenerator = new MockSecretSolutionGenerator();
            var mastermind = new Mastermind(secretSolutionGenerator);

            mastermind.SetSecretSolution(_colours);
            var peg1     = new Peg(Colour.Red);
            var peg2     = new Peg(Colour.Blue);
            var peg3     = new Peg(Colour.Yellow);
            var peg4     = new Peg(Colour.Yellow);
            var solution = new[] { peg1, peg2, peg3, peg4 };
            var hint     = mastermind.CreateHintBasedOnPlayerSolution(solution);

            Assert.Equal(Value.Black, hint[0].Value);
            Assert.Equal(Value.Black, hint[1].Value);
            Assert.Equal(Value.Empty, hint[2].Value);
            Assert.Equal(Value.Empty, hint[3].Value);
        }
Example #3
0
        public void CreateHintBasedOnPlayerSolutionShould_CreateCorrectHintWithAllEmptyValues_BasedOnPlayerSolution()
        {
            var secretSolutionGenerator = new MockSecretSolutionGenerator();
            var mastermind = new Mastermind(secretSolutionGenerator);

            mastermind.SetSecretSolution(_colours);
            var peg1     = new Peg(Colour.Yellow);
            var peg2     = new Peg(Colour.Yellow);
            var peg3     = new Peg(Colour.Yellow);
            var peg4     = new Peg(Colour.Yellow);
            var solution = new[] { peg1, peg2, peg3, peg4 };
            var hint     = mastermind.CreateHintBasedOnPlayerSolution(solution);

            foreach (var item in hint)
            {
                Assert.Equal(Value.Empty, item.Value);
            }
        }