Exemplo n.º 1
0
        public void TextureAtlas_GetRegionsByName_Test()
        {
            var texture = new Texture2D(TestHelper.CreateGraphicsDevice(), 100, 200);
            var atlas = new TextureAtlas(texture);

            var region0 = atlas.CreateRegion("region0", 10, 20, 30, 40);
            var region1 = atlas.CreateRegion("region1", 50, 60, 35, 45);

            Assert.AreSame(region0, atlas["region0"]);
            Assert.AreSame(region1, atlas["region1"]);
            Assert.AreSame(region0, atlas.GetRegion("region0"));
            Assert.AreSame(region1, atlas.GetRegion("region1"));
        }
Exemplo n.º 2
0
        public void TextureAtlas_GetRegion_InvalidIndexThrowsException_Test()
        {
            var texture = new Texture2D(TestHelper.CreateGraphicsDevice(), 100, 200);
            var atlas = new TextureAtlas(texture);

            atlas.CreateRegion("region0", 10, 20, 30, 40);

            atlas.GetRegion(-1);
        }
        public void TextureAtlas_GetRegion_InvalidNameThrowsException_Test()
        {
            var texture = new Texture2D(TestHelper.CreateGraphicsDevice(), 100, 200);
            var atlas = new TextureAtlas(texture);

            atlas.CreateRegion("region0", 10, 20, 30, 40);
            Assert.Throws<KeyNotFoundException>(() => atlas.GetRegion("region1"));
        }