public void TestSetup() { _eventsFired = EventFlags.None; _registry = new TileRegistry(_service.GraphicsDevice); _pool = new TilePool("pool", _registry, 16, 16); Texture2D tex1 = new Texture2D(_service.GraphicsDevice, 16, 16); Texture2D tex2 = new Texture2D(_service.GraphicsDevice, 16, 16); _tile1 = _pool.GetTile(_pool.AddTile(tex1)); _tile2 = _pool.GetTile(_pool.AddTile(tex2)); }
public void RemoveTileNotPresentTest() { TileStack stack = new TileStack(); stack.Add(_tile1); stack.Add(_tile2); AttachEvents(stack); Texture2D texture = new Texture2D(_service.GraphicsDevice, 16, 16); Tile tile3 = _pool.GetTile(_pool.AddTile(texture)); stack.Remove(tile3); Assert.AreEqual(EventFlags.None, _eventsFired); Assert.AreEqual(2, stack.Count); Assert.AreEqual(_tile1, stack[0]); Assert.AreEqual(_tile2, stack[1]); }
public void AddTileOverCapacity() { using (FileStream fs = File.OpenRead("TestContent/purple_caves.png")) { TilePool pool = TilePool.Import("Test", _registry, fs, 16, 16); Texture2D tex = new Texture2D(_service.GraphicsDevice, 16, 16); pool.TileAdded += (s, e) => { Assert.AreEqual(pool, e.Tile.Pool); Assert.AreEqual(tex.Width, e.Tile.Width); Assert.AreEqual(tex.Height, e.Tile.Height); }; int id = pool.AddTile(tex); Assert.AreEqual(65, _registry.TileCount); Assert.AreEqual(65, pool.Count); Assert.AreEqual(128, pool.Capacity); } }
public void AddTile() { Assert.AreEqual(0, _registry.TileCount); Assert.AreEqual(0, _pool.Count); Texture2D tex = new Texture2D(_service.GraphicsDevice, 16, 16); _pool.TileAdded += (s, e) => { Assert.AreEqual(_pool, e.Tile.Pool); Assert.AreEqual(tex.Width, e.Tile.Width); Assert.AreEqual(tex.Height, e.Tile.Height); }; int id = _pool.AddTile(tex); Assert.AreEqual(EventFlags.Modified | EventFlags.TileAdded, _eventsFired); Assert.AreEqual(1, _registry.TileCount); Assert.AreEqual(1, _pool.Count); }