Exemplo n.º 1
0
        public void TestRoundtrip()
        {
            var obj = new TestTimeSpan()
            {
                Span         = new TimeSpan(1, 1, 1, 1, 1),
                OptionalSpan = new TimeSpan(2, 2, 2, 2, 2)
            };

            var doc = obj.ToBsonDocument();

            Assert.AreEqual("{ \"Span\" : 90061001.0, \"OptionalSpan\" : 180122002.0 }", doc.ToString());

            var obj2 = BsonSerializer.Deserialize <TestTimeSpan>(doc);

            Assert.AreEqual(obj.Span, obj2.Span);
            Assert.AreEqual(obj.OptionalSpan, obj2.OptionalSpan);

            // TODO: How to unregister a serializer?
            // BsonSerializer.RegisterSerializer(typeof(TimeSpan), new OriginalTimeSpanSerializer());
        }
Exemplo n.º 2
0
        public void TestRoundtrip()
        {
            var obj = new TestTimeSpan()
            {
                Span = new TimeSpan(1, 1, 1, 1, 1),
                OptionalSpan = new TimeSpan(2, 2, 2, 2, 2)
            };

            var doc = obj.ToBsonDocument();

            Assert.AreEqual("{ \"Span\" : 90061001.0, \"OptionalSpan\" : 180122002.0 }", doc.ToString());

            var obj2 = BsonSerializer.Deserialize<TestTimeSpan>(doc);

            Assert.AreEqual(obj.Span, obj2.Span);
            Assert.AreEqual(obj.OptionalSpan, obj2.OptionalSpan);

            // TODO: How to unregister a serializer?
            // BsonSerializer.RegisterSerializer(typeof(TimeSpan), new OriginalTimeSpanSerializer());
        }