Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Rendering2D.Tests SpriteSaveAndLoadTests
Namespace: DeltaEngine.Rendering2D.Tests
Assembly: DeltaEngine.Rendering2D.Tests (in DeltaEngine.Rendering2D.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The SpriteSaveAndLoadTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
SpriteSaveAndLoadTests | Initializes a new instance of the SpriteSaveAndLoadTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
CreateSpriteFromComponents | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
SaveAndLoadSprite |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, CloseAfterFirstFrame] public void CreateSpriteFromComponents() { var components = new List<object>(); components.Add(Rectangle.One); components.Add(true); var material = new Material(ShaderFlags.Position2DTextured, "DeltaEngineLogo"); components.Add(material); components.Add(material.DiffuseMap.BlendMode); components.Add(new RenderingData()); var sprite = Activator.CreateInstance(typeof(Sprite), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, null, CultureInfo.CurrentCulture) as Sprite; sprite.SetComponents(components); Assert.AreEqual(material, sprite.Material); Assert.AreEqual(Rectangle.One, sprite.DrawArea); Assert.AreEqual(material.DiffuseMap.BlendMode, sprite.BlendMode); }
[Test, CloseAfterFirstFrame] public void SaveAndLoadSprite() { var sprite = new Sprite("DeltaEngineLogo", Rectangle.One); var data = BinaryDataExtensions.SaveToMemoryStream(sprite); Assert.Greater(data.Length, 0); var loadedSprite = data.CreateFromMemoryStream() as Sprite; Assert.AreEqual(sprite.Material.Shader, loadedSprite.Material.Shader); Assert.AreEqual(sprite.Material.DiffuseMap, loadedSprite.Material.DiffuseMap); Assert.AreEqual(sprite.DrawArea, loadedSprite.DrawArea); Assert.AreEqual(sprite.BlendMode, loadedSprite.BlendMode); Assert.AreEqual(sprite.Rotation, loadedSprite.Rotation); Assert.AreEqual(1, loadedSprite.GetActiveBehaviors().Count); Assert.AreEqual(1, loadedSprite.GetDrawBehaviors().Count); Assert.AreEqual("SpriteRenderer", loadedSprite.GetDrawBehaviors()[0].GetShortNameOrFullNameIfNotFound()); }
See Also