public void WriteStringReadGuid() { StringTestClass c = new StringTestClass(); c.AGuid = new Guid("af45dccf-df13-44fe-82be-6212c09eda84").ToString(); MemoryStream ms = new MemoryStream(); JsonSerializer serializer = new JsonSerializer(); BsonDataWriter writer = new BsonDataWriter(ms); serializer.Serialize(writer, c); ms.Seek(0, SeekOrigin.Begin); BsonDataReader reader = new BsonDataReader(ms); GuidTestClass c2 = serializer.Deserialize <GuidTestClass>(reader); Assert.AreEqual(c.AGuid, c2.AGuid.ToString()); }
public void String_With_MemoryStream() { using (var stream = new MemoryStream()) { { StringTestClass testObject = new StringTestClass(); testObject.String = "This string was brought to you by Crytek"; var writer = new ObjectWriter(stream); writer.Write(testObject); } var reader = new ObjectReader(stream); var readObject = reader.Read(); Assert.AreSame(readObject.GetType(), typeof(StringTestClass)); var parsedObject = (StringTestClass)readObject; Assert.AreEqual(parsedObject.String, "This string was brought to you by Crytek"); } }
public void Generic_Static_Delegate_With_MemoryStream() { using (var stream = new MemoryStream()) { { var stringClass1 = new StringTestClass(); stringClass1.String = "Testing1"; var stringClass2 = new StringTestClass(); stringClass2.String = "Testing2"; GenericEvent += DomainSerializerTests_GenericEvent; var assembly = Assembly.GetExecutingAssembly(); var writer = new ObjectWriter(stream); writer.WriteStatics(assembly); } var reader = new ObjectReader(stream); reader.ReadStatics(); } }
public void WriteStringReadGuid() { StringTestClass c = new StringTestClass(); c.AGuid = new Guid("af45dccf-df13-44fe-82be-6212c09eda84").ToString(); MemoryStream ms = new MemoryStream(); JsonSerializer serializer = new JsonSerializer(); BsonWriter writer = new BsonWriter(ms); serializer.Serialize(writer, c); ms.Seek(0, SeekOrigin.Begin); BsonReader reader = new BsonReader(ms); GuidTestClass c2 = serializer.Deserialize<GuidTestClass>(reader); Assert.AreEqual(c.AGuid, c2.AGuid.ToString()); }