Esempio n. 1
0
        public void Works()
        {
            var numbers = randoom.GetSequence(35, 3, 27);

            Assert.True(numbers.TrueForAll(i => i >= 3 && i <= 27), "All numbers must be in range");
            var firstRun = string.Join("", numbers);

            numbers = randoom.GetSequence(35, 0, 27);

            Assert.True(numbers.TrueForAll(i => i >= 0 && i <= 27), "All numbers must be in range");
            var secondRun = string.Join("", numbers);

            Assert.NotEqual(firstRun, secondRun);
        }
Esempio n. 2
0
        /// <summary>
        /// Generate the code
        /// </summary>
        /// <param name="length">How long the code should be</param>
        /// <param name="numberOfOptions">How many possible values each slot can hove</param>
        /// <exception cref="InvalidOperationException">Thrown if the instance already has a code</exception>
        public virtual void GenerateCode(int length, int numberOfOptions)
        {
            if (Code != default(Code))
            {
                throw new InvalidOperationException("I already have a code!");
            }

            Code = new Code();
            Code.Slots.AddRange(rng.GetSequence(length, 0, numberOfOptions));
        }
        public CodeMakerTests()
        {
            randoom = A.Fake <Randoom>();

            A.CallTo(() => randoom.GetSequence(A <int> ._, A <int> ._, A <int> ._)).Returns(new List <int> {
                4
            });

            maker = new CodeMaker(randoom);
        }
        public void GenerateCode_usesRandoom_toGetValues()
        {
            maker.GenerateCode(15, 666);

            A.CallTo(() => randoom.GetSequence(15, 0, 666)).MustHaveHappened();
        }