Namespace: DeltaEngine.Tests.Datatypes
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Examples
[Test] public void SaveAndLoadRectangle() { var data = BinaryDataExtensions.SaveToMemoryStream(Rectangle.One); byte[] savedBytes = data.ToArray(); Assert.AreEqual(1 + 4 + "Rectangle".Length + Rectangle.SizeInBytes, savedBytes.Length); Assert.AreEqual("Rectangle".Length, savedBytes[0]); var reconstructed = data.CreateFromMemoryStream(); Assert.AreEqual(Rectangle.One, reconstructed); }
[Test] public void SaveAndLoadRectangleManuallyWithBinaryWriterAndReader() { using (var dataStream = new MemoryStream()) { var writer = new BinaryWriter(dataStream); var data = Rectangle.One; BinaryDataExtensions.Save(data, writer); dataStream.Seek(0, SeekOrigin.Begin); var reader = new BinaryReader(dataStream); data = (Rectangle)reader.Create(); Assert.AreEqual(Rectangle.One, data); } }
See Also