9using System.Collections.Generic;
12using Microsoft.VisualStudio.TestTools.UnitTesting;
32 _testDIContext = TestDIContextFactory.CreateDefaultContext();
35 #region Serialize then Deserialize
46 Point deserializedPoint;
49 deserializedPoint = SerializeThenDeserialisePoint(point);
50 actual = deserializedPoint.
X;
53 Assert.AreEqual(expected, actual);
66 Point deserializedPoint;
69 deserializedPoint = SerializeThenDeserialisePoint(point);
70 actual = deserializedPoint.
Y;
73 Assert.AreEqual(expected, actual);
79 #region Private Helper Methods
81 private Point SerializeThenDeserialisePoint(
Point valueToSerialize)
83 var applicationContext = _testDIContext.CreateTestApplicationContext();
85 System.IO.MemoryStream serializationStream;
86 Nullable<Point> deserializedValue;
90 using (serializationStream =
new System.IO.MemoryStream())
92 formatter.
Serialize(serializationStream, valueToSerialize);
93 serializationStream.Seek(0, System.IO.SeekOrigin.Begin);
94 deserializedValue = formatter.
Deserialize(serializationStream) as Nullable<Point>;
97 return deserializedValue.Value;
Tests of serialization of the Point struct
void SerializeThenDeserialize_PointWithYOf17_HasYOf17()
void SerializeThenDeserialize_PointWithXOf21_HasXOf21()
static void ClassInitialize(TestContext testContext)
Type to carry context information for DI in unit tests
Struct that can be used for testing serialization behaviour