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); }
public void ShouldRollPositionInRoomWithMarginForWall() { // given var roomSize = new Size(20, 20); const int marginForWall = 1; // when var roomPositionX = new List <int>(); var roomPositionY = new List <int>(); for (var i = 0; i < 100000; i++) { var position = _yoloDice.RollPosition(roomSize.Width, roomSize.Height); roomPositionX.Add(position.X); roomPositionY.Add(position.Y); } // then Assert.That(roomPositionX, Is.All.InRange(1, roomSize.Width - marginForWall)); Assert.That(roomPositionY, Is.All.InRange(1, roomSize.Height - marginForWall)); }