Example #1
0
        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 WriteReadGuid()
        {
            GuidTestClass c = new GuidTestClass();
            c.AGuid = new Guid("af45dccf-df13-44fe-82be-6212c09eda84");

            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);
        }