Пример #1
0
        public void SpriteFromSheetTests()
        {
            var fromNullSheet = new SpriteFromSheet();
            Assert.AreEqual(0, fromNullSheet.SpritesCount);
            Assert.IsNull(fromNullSheet.GetSprite(0));

            var emptySheet = new SpriteSheet();
            var fromEmptySheet = new SpriteFromSheet { Sheet = emptySheet };
            Assert.AreEqual(0, fromEmptySheet.SpritesCount);
            Assert.IsNull(fromEmptySheet.GetSprite(0));

            var nullList = new SpriteSheet { Sprites = null };
            var fromnullListSheet = new SpriteFromSheet { Sheet = nullList };
            Assert.AreEqual(0, fromnullListSheet.SpritesCount);
            Assert.IsNull(fromnullListSheet.GetSprite(0));
            
            var emptyList = new SpriteSheet { Sprites = new List<Sprite>() };
            var fromEmptyListSheet = new SpriteFromSheet { Sheet = emptyList };
            Assert.AreEqual(0, fromEmptyListSheet.SpritesCount);
            Assert.IsNull(fromEmptyListSheet.GetSprite(0));

            var validSheet = new SpriteSheet() { Sprites = new List<Sprite> { new Sprite("0"), new Sprite("1") } };
            var fromValidSheet = new SpriteFromSheet { Sheet = validSheet };
            Assert.AreEqual(2, fromValidSheet.SpritesCount);
            for (int i = 0; i < fromValidSheet.SpritesCount; i++)
            {
                Assert.AreEqual(i.ToString(), fromValidSheet.GetSprite(i).Name);
            }
        }
        public void SpriteFromSheetTests()
        {
            var fromNullSheet = new SpriteFromSheet();
            Assert.AreEqual(0, fromNullSheet.SpritesCount);
            Assert.IsNull(fromNullSheet.GetSprite());

            var emptySheet = new SpriteSheet();
            var fromEmptySheet = new SpriteFromSheet { Sheet = emptySheet };
            Assert.AreEqual(0, fromEmptySheet.SpritesCount);
            Assert.IsNull(fromEmptySheet.GetSprite());

            var validSheet = new SpriteSheet { Sprites = { new Sprite("0"), new Sprite("1") } };
            var fromValidSheet = new SpriteFromSheet { Sheet = validSheet };
            Assert.AreEqual(2, fromValidSheet.SpritesCount);
            for (var i = 0; i < fromValidSheet.SpritesCount; i++)
            {
                fromValidSheet.CurrentFrame = i;
                Assert.AreEqual(i.ToString(), fromValidSheet.GetSprite().Name);
            }
        }
Пример #3
0
 /// <summary>
 /// Creates a new instance of <see cref="SpriteComponent"/>
 /// </summary>
 public SpriteComponent()
 {
     SpriteProvider = new SpriteFromSheet();
     PremultipliedAlpha = true;
 }