private void SetupHeightmapPage() { const int width = 3; const int height = 3; var mock = new Mock<IHeightmapPage>(); mock.SetupGet(heightmap => heightmap.Width).Returns(width); mock.SetupGet(heightmap => heightmap.Height).Returns(height); for (int x = 0; x < width; x++) { for(int y = 0; y < height; y++) { int xPosition = x; int yPosition = y; if (xPosition < (width - 1) && yPosition < (height - 1)) { mock.SetupGet(heightmap => heightmap[xPosition, yPosition]) .Returns(0); } else { mock.SetupGet(heightmap => heightmap[xPosition, yPosition]) .Returns(2); } } } _mockHeightmapPage = mock.Object; }
public HeightmapTextureProcessor(IHeightmapPage heightmapPage, ITextureGroupResolver textureGroupResolver, ITextureGroupTransitionRepository textureGroupTransitionRepository, IRandomGenerator randomGenerator) { _heightmapPage = heightmapPage; _textureGroupResolver = textureGroupResolver; _textureGroupTransitionRepository = textureGroupTransitionRepository; _randomGenerator = randomGenerator; _textures = new Lazy<short[,]>(InitializeTextures); }
public HeightmapPageTextureGroupResolver(IHeightmapPage heightmapPagePage, ITextureGroupRepository<TextureGroupRange> textureGroupRepository) { if(heightmapPagePage == null) { throw new ArgumentNullException("heightmapPagePage"); } if(textureGroupRepository == null) { throw new ArgumentNullException("textureGroupRepository"); } _heightmapPage = heightmapPagePage; _textureGroupRepository = textureGroupRepository; _textureGroupRangeIndex = new Lazy<IList<TextureGroupRange>>(InitializeTextureGroupRangeIndex); }
private void SetupHeightmapMock() { var mock = new Mock<IHeightmapPage>(); mock.SetupGet(heightmap => heightmap.Height).Returns(8); mock.SetupGet(heightmap => heightmap.Width).Returns(8); var random = new Random(); //Upper-left quadrant mock.Setup(heightmap => heightmap[It.IsInRange(0, 3, Range.Inclusive), It.IsInRange(0, 3, Range.Inclusive)]) .Returns(() => random.Next(0, 50)); //Upper-right quadrant mock.Setup(heightmap => heightmap[It.IsInRange(4, 7, Range.Inclusive), It.IsInRange(0, 3, Range.Inclusive)]) .Returns(() => random.Next(51, 150)); //Lower-left quadrant mock.Setup(heightmap => heightmap[It.IsInRange(0, 3, Range.Inclusive), It.IsInRange(4, 7, Range.Inclusive)]) .Returns(() => random.Next(151, 200)); //Lower-right quadrant mock.Setup(heightmap => heightmap[It.IsInRange(4, 7, Range.Inclusive), It.IsInRange(4, 7, Range.Inclusive)]) .Returns(() => random.Next(201, 255)); _mockHeightmapPage = mock.Object; }