EntityTests SaveAndLoadEntityWithTwoComponentsFromMemoryStream 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 SaveAndLoadEntityWithTwoComponentsFromMemoryStream()
Examples

[Test]
public void SaveAndLoadEntityWithTwoComponentsFromMemoryStream()
{
    entityWithTags.Add(1).Add(0.1f);
    var data = BinaryDataExtensions.SaveToMemoryStream(entityWithTags);
    var loadedEntity = data.CreateFromMemoryStream() as Entity;
    Assert.AreEqual(60, data.ToArray().Length);
    Assert.AreEqual(2, loadedEntity.NumberOfComponents);
    Assert.AreEqual(1, entityWithTags.Get<int>());
    Assert.AreEqual(0.1f, entityWithTags.Get<float>());
    Assert.IsTrue(loadedEntity.ContainsTag(Tag1));
    Assert.IsTrue(loadedEntity.IsActive);
    Assert.AreEqual(0, loadedEntity.GetActiveBehaviors().Count);
}
See Also