BinaryDataLoadSaveTests SaveAndLoadClassWithAnotherClassInside Method Delta Engine Documentation

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

public void SaveAndLoadClassWithAnotherClassInside()
Examples

[Test]
public void SaveAndLoadClassWithAnotherClassInside()
{
    var instance = new ClassWithAnotherClassInside
    {
        Number = 17,
        Data =
            new ClassWithAnotherClassInside.InnerDerivedClass { Value = 1.5, additionalFlag = true },
        SecondInstanceNotSet = null
    };
    var data = BinaryDataExtensions.SaveDataIntoMemoryStream(instance);
    var retrieved =
        BinaryDataExtensions.LoadDataWithKnownTypeFromMemoryStream<ClassWithAnotherClassInside>(
            data);
    Assert.AreEqual(instance.Number, retrieved.Number);
    Assert.AreEqual(instance.Data.Value, retrieved.Data.Value);
    Assert.AreEqual(instance.Data.additionalFlag, retrieved.Data.additionalFlag);
    Assert.AreEqual(instance.SecondInstanceNotSet, retrieved.SecondInstanceNotSet);
}
See Also