SpriteSaveAndLoadTests SaveAndLoadSprite Method Delta Engine Documentation

Namespace: DeltaEngine.Rendering2D.Tests
Assembly: DeltaEngine.Rendering2D.Tests (in DeltaEngine.Rendering2D.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public void SaveAndLoadSprite()
Examples

[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