コード例 #1
0
        public void Should__IndicateSuccess__When__GuessMatchesAnswer()
        {
            // arrange
            Combination combination =
                new CombinationBuilder()
                .WithLength(4)
                .UsingDigitsBetween(1, 6);

            string guess = combination.GetAnswer();

            // act
            GuessResult result = combination.Try(guess);

            // assert
            result.WasRight.Should().BeTrue();
            result.ToString().Should().Be("++++");
        }
コード例 #2
0
        public void Should__GenerateCombinationWithDigitsInRange__When__ValidRangeGiven()
        {
            // arrange
            List <int> range             = Enumerable.Range(1, 3).ToList();
            const int  combinationLength = 10;

            // act
            Combination combination =
                new CombinationBuilder()
                .WithLength(combinationLength)
                .UsingDigitsBetween(range.First(), range.Last());

            string answer = combination.GetAnswer();

            // assert
            answer.ToArray().All(c => range.Contains(c - 48)).Should().BeTrue();
        }