public void SetUp() { texture = new Mock<ITexture>(); texture.SetupGet(t => t.Width).Returns(200); texture.SetupGet(t => t.Height).Returns(50); var textureRegion = new TextureRegion(2, 2, 15, 20); spriteSheet = new Mock<ISpriteSheet>(); spriteSheet.SetupGet(s => s.Texture) .Returns(texture.Object); spriteSheet.Setup(s => s.GetRegion(It.IsAny<int>())) .Returns(textureRegion); spriteSheet.SetupGet(s => s.TextureRegions) .Returns(new TextureRegion[] { textureRegion }); shaderProgram = new Mock<IShaderProgram>(); var mvpUniform = new ShaderUniform("mvp", 4, 16, ActiveUniformType.FloatMat4); var uniforms = new Dictionary<string, ShaderUniform>() { {"mvp", mvpUniform} }; shaderProgram.SetupGet(s => s.Uniforms).Returns(uniforms); vao = new Mock<IVertexArrayObject>(); vbo = new Mock<IVertexBuffer<VertexPositionColourTexture>>(); vbo.SetupGet(v => v.VertexDeclaration).Returns(declaration); adapter = new Mock<IDrawAdapter>(); spriteBatch = new SpriteBatch( spriteSheet.Object, shaderProgram.Object, vao.Object, vbo.Object, adapter.Object ); }
public void Add(TextureRegion textureRegion) { if (textureRegion == null) { throw new ArgumentNullException(nameof(textureRegion)); } regions.Add(textureRegion); }
public void TextureRegions_Contain_ExpectedRegions(TextureRegion expected) { spriteSheet.TextureRegions.Length.ShouldBe(6); spriteSheet.TextureRegions.ShouldContain(r => r.X == expected.X && r.Y == expected.Y && r.Width == expected.Width && r.Height == expected.Height ); }
public void Constructor_CorrectlyInitialises_Instance() { var region = new TextureRegion(0, 0, 50, 50); var frame = new Frame(region, 0.1); frame.ShouldSatisfyAllConditions( () => frame.TextureRegion.ShouldBe(region), () => frame.Duration.ShouldBe(0.1) ); }
public void Constructor_CorrectlyInitialises_Instance() { var region = new TextureRegion(10, 2, 16, 24); region.ShouldSatisfyAllConditions( () => region.X.ShouldBe(10), () => region.Y.ShouldBe(2), () => region.Width.ShouldBe(16), () => region.Height.ShouldBe(24) ); }
public void Parse_ReturnsExpected_TextureRegions(TextureRegion expected) { var atlas = parser.Parse(dataFilePath); atlas.TextureRegions.ShouldContain(r => r.X == expected.X && r.Y == expected.Y && r.Width == expected.Width && r.Height == expected.Height ); }
public void SetUp() { region = new TextureRegion(0, 0, 20, 25); frames = new Frame[] { new Frame(region, 0.1), new Frame(region, 0.2) }; animation = new Animation(frames); loopingAnimation = new Animation(true, frames); }
public Sprite(TextureRegion textureRegion, int x, int y, Colour4 colour) { if (textureRegion == null) { throw new ArgumentNullException(nameof(textureRegion)); } this.textureRegion = textureRegion; this.x = x; this.y = y; this.width = textureRegion.Width; this.height = textureRegion.Height; this.colour = colour; }
public Sprite(TextureRegion textureRegion, int x, int y) : this(textureRegion, x, y, Colour4.White) { }
private void AssertExpectedRegion(TextureRegion region) { region.ShouldSatisfyAllConditions( () => region.X.ShouldBe(2), () => region.Y.ShouldBe(2), () => region.Width.ShouldBe(16), () => region.Height.ShouldBe(24) ); }