private static void CheckInt32(int expectedValue, int expectedSize) { IFieldWriter writer = new FieldWriter(new MemoryStream()); writer.Write(expectedValue); IFieldReader reader = new FieldReader(writer.ToArray()); int actualValue = reader.ReadInt32(); Assert.AreEqual(expectedValue, actualValue, "Expected deserialized value "); if (expectedSize > 0) { Assert.AreEqual(expectedSize, writer.Position, "Unexpected size for {0} ", expectedValue); } }