コード例 #1
0
        public void ShouldRollNumberFrom1To100WhenRolingK100()
        {
            // when
            var result = _yoloDice.RollK100();

            // then
            Assert.That(result, Is.InRange(1, 100));
        }
コード例 #2
0
        private Dice GetDiceMock()
        {
            var realDice = new YoloDice();
            var diceMock = A.Fake <Dice>();

            A.CallTo(() => diceMock.RollK100()).Returns(realDice.RollK100());
            A.CallTo(() => diceMock.RollBetween(A <int> .Ignored, A <int> .Ignored))
            .ReturnsLazily((int low, int high) => realDice.RollBetween(low, high));
            A.CallTo(() => diceMock.RollChance(A <int> .Ignored)).ReturnsLazily((int chance) => realDice.RollChance(chance));
            A.CallTo(() => diceMock.RollPosition(A <int> .Ignored, A <int> .Ignored))
            .ReturnsLazily((int width, int height) => realDice.RollPosition(width, height));

            return(diceMock);
        }