public void ReadWriteComplexTest() { MemoryStream ms = new MemoryStream(); // serialize some data XmlWriterMock writer = new XmlWriterMock(new StreamAdapter(ms)); DateTime dat = new DateTime(2002, 2, 2, 2, 2, 2); // 02.02.2002 02:02:02 writer.Write(dat); string str = "test string"; writer.Write(str); int integer = 223344; writer.Write(integer); float single = 1.2345f; writer.Write(single); byte[] bytes = new byte[] {5,4,3,2,1}; writer.Write(bytes); long int64 = 1234567890; writer.Write(int64); ms.Position = 0; // deserialize serialized data XmlReaderMock reader = new XmlReaderMock(new StreamAdapter(ms)); DateTime adat = reader.ReadDateTime(); Assert.AreEqual(dat, adat); string astr = reader.ReadString(); Assert.AreEqual(str, astr); int aint = reader.ReadInt32(); Assert.AreEqual(integer, aint); float asingle = reader.ReadSingle(); Assert.AreEqual(single, asingle); byte[] abytes = reader.ReadBytes(bytes.Length); MyAssert.AreEqual(bytes, abytes); long aint64 = reader.ReadInt64(); Assert.AreEqual(int64, aint64); }
public void ReadWriteInt64Test() { MemoryStream ms = new MemoryStream(); // serialize some data XmlWriterMock writer = new XmlWriterMock(new StreamAdapter(ms)); long a = 1234567890123456789; writer.Write(a); ms.Position = 0; string actual = Encoding.UTF8.GetString(ms.ToArray()); string expected = "<long>" + a + "</long>"; Assert.AreEqual(actual, expected); // deserialize serialized data XmlReaderMock reader = new XmlReaderMock(new StreamAdapter(ms)); long b = reader.ReadInt64(); Assert.AreEqual(a, b); }