BinaryDataExtensionsTests ExpectExceptionForUnreadableData 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 ExpectExceptionForUnreadableData()
Examples

[Test]
public void ExpectExceptionForUnreadableData()
{
    var message = new TestMessage { content = "This message cannot be resolved!", ID = 0 };
    var memoryStream = new MemoryStream(new byte[64]);
    var binaryWriter = new BinaryWriter(memoryStream);
    binaryWriter.Write(BinaryDataExtensions.ToByteArray(message));
    memoryStream.Position = 0;
    var binaryReader = new BinaryReader(memoryStream);
    Assert.Throws<TypeLoadException>(() => binaryReader.Create());
}
See Also