EntityTests SaveAndLoadEntityWithTwoBehaviorsFromMemoryStream Method Delta Engine Documentation

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

public void SaveAndLoadEntityWithTwoBehaviorsFromMemoryStream()
Examples

[Test]
public void SaveAndLoadEntityWithTwoBehaviorsFromMemoryStream()
{
    entityWithTags.Start<MockUpdateBehavior>().Start<CreateEntityStartAndStopBehavior>();
    var data = BinaryDataExtensions.SaveToMemoryStream(entityWithTags);
    var loadedEntity = data.CreateFromMemoryStream() as Entity;
    Assert.AreEqual(0, loadedEntity.NumberOfComponents);
    Assert.AreEqual(2, loadedEntity.GetActiveBehaviors().Count);
    Assert.AreEqual(96, data.ToArray().Length);
    Assert.AreEqual("MockUpdateBehavior",
        loadedEntity.GetActiveBehaviors()[0].GetShortNameOrFullNameIfNotFound());
    Assert.AreEqual("CreateEntityStartAndStopBehavior",
        loadedEntity.GetActiveBehaviors()[1].GetShortNameOrFullNameIfNotFound());
}
See Also