Пример #1
0
        public void PassingAllCorrectColorsInCorrectOrderReturnsAllBlack()
        {
            var expected          = new[] { PinResult.Black, PinResult.Black, PinResult.Black, PinResult.Black };
            var computerPinColors = new[] { PinColor.Blue, PinColor.Green, PinColor.Red, PinColor.White };
            var userPinColors     = new[] { PinColor.Blue, PinColor.Green, PinColor.Red, PinColor.White };
            var sut    = new Mastermind(computerPinColors);
            var result = sut.Check(userPinColors);

            Assert.Equal(expected, result);
        }
Пример #2
0
        public void PassingNoCorrectColorsReturnsEmptyResults()
        {
            var expected          = new PinResult[] { };
            var computerPinColors = new[] { PinColor.Blue, PinColor.Blue, PinColor.Blue, PinColor.Blue };
            var userPinColors     = new[] { PinColor.Red, PinColor.Red, PinColor.Red, PinColor.Red };
            var sut    = new Mastermind(computerPinColors);
            var result = sut.Check(userPinColors);

            Assert.Equal(expected, result);
        }
Пример #3
0
        public void PassingOneCorrectColorsInCorrectPositionReturnsOneBlackPeg()
        {
            var expected          = new[] { PinResult.Black };
            var computerPinColors = new[] { PinColor.Blue, PinColor.Blue, PinColor.Blue, PinColor.Blue };
            var userPinColors     = new[] { PinColor.Blue, PinColor.Red, PinColor.Red, PinColor.Red };
            var sut    = new Mastermind(computerPinColors);
            var result = sut.Check(userPinColors);

            Assert.Equal(expected, result);
        }
Пример #4
0
        public void ReturnCorrectUsageMask()
        {
            var         computerPinColors = new[] { PinColor.Green, PinColor.Blue, PinColor.Blue, PinColor.Blue };
            var         sut    = new Mastermind(computerPinColors);
            List <bool> unused = new List <bool>()
            {
                true, true, true, true
            };
            IEnumerable <PinColor> result = sut.GetMaskedPins(computerPinColors, unused);
            var expected = new List <PinColor>()
            {
                PinColor.Green, PinColor.Blue, PinColor.Blue, PinColor.Blue
            };

            Assert.Equal(result, expected);
        }
Пример #5
0
        public void SolveScenario()
        {
            var computerSelection = new List <string>()
            {
                "Red", "Blue", "Green", "Yellow"
            };
            var sut = new Mastermind(computerSelection);

            Assert(sut, new List <string> {
                "Red", "Orange", "Yellow", "Orange"
            }, new[] { PinResult.Black, PinResult.White });
            Assert(sut, new List <string> {
                "Blue", "Red", "Yellow", "Green"
            }, new[] { PinResult.White, PinResult.White, PinResult.White, PinResult.White });
            Assert(sut, new List <string> {
                "Red", "Red", "Red", "Red"
            }, new[] { PinResult.White });
            Assert(sut, new List <string> {
                "White", "White", "White", "White"
            }, new PinResult[] {});
            Assert(sut, new List <string> {
                "Red", "Blue", "Green", "Yellow"
            }, new[] { PinResult.Black, PinResult.Black, PinResult.Black, PinResult.Black });
        }
Пример #6
0
        private static void Assert(Mastermind sut, IReadOnlyCollection <string> readOnlyCollection, IEnumerable <PinResult> pinResults)
        {
            var result1 = sut.Check(readOnlyCollection);

            Xunit.Assert.Equal(pinResults, result1);
        }