예제 #1
0
        public void DieRollHasSufficientProbabilityToAlwaysBeBetween1And6()
        {
            SixSidedDie die = new SixSidedDie();

            for (int i = 0; i < 10000; i++)
            {
                Assert.IsTrue(die.Roll() >= 1 && die.Roll() <= 6);
            }
        }
예제 #2
0
        public void ReturnResultFromRandom()
        {
            var mocker = new AutoMoqer();

            mocker.GetMock <Random>()
            .Setup(x => x.Next(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(5);

            var service = mocker.Create <RollDieService>();

            var die    = new SixSidedDie();
            var result = service.Handle(new RollDieRequest {
                Die = die
            }, CancellationToken.None).Result;

            Assert.IsNotNull(result);
            Assert.AreEqual(die, result.Die);
            Assert.AreEqual(5, result.Value);
        }