public void ShouldSerializeClass()
        {
            // Given

            var time1 = Time.Now.AddSeconds(1.456);
            var time2 = Time.Now.AddSeconds(2.789);
            var time3 = Time.Now.AddSeconds(3.012);

            var serializer = JsonObjectSerializer.Default;

            var instance = new TimeClassExample
            {
                TimeProperty         = time1,
                NullableTimeProperty = time2,
                ComplexProperty      = new TimeClassExample
                {
                    TimeProperty = time3
                }
            };

            var expectedJson = @"{" +
                               "\"TimeProperty\":" + time1.TotalSeconds.ToString("r", CultureInfo.InvariantCulture) + "," +
                               "\"NullableTimeProperty\":" + time2.TotalSeconds.ToString("r", CultureInfo.InvariantCulture) + "," +
                               "\"ComplexProperty\":{" +
                               "\"TimeProperty\":" + time3.TotalSeconds.ToString("r", CultureInfo.InvariantCulture) +
                               "}" +
                               "}";

            // When
            var actualJson = serializer.ConvertToString(instance);

            // Then
            Assert.AreEqual(expectedJson, actualJson);
        }
        public void ShouldSaveClassWithTime()
        {
            // Given

            var time1 = Time.Now.AddDays(1);
            var time2 = Time.Now.AddDays(2);
            var time3 = Time.Now.AddDays(3);

            var instance = new TimeClassExample
            {
                _id                  = 1,
                TimeProperty         = time1,
                NullableTimeProperty = time2,
                ComplexProperty      = new TimeClassExample
                {
                    TimeProperty = time3
                }
            };

            var classStorage   = MongoTestHelpers.GetEmptyStorageProvider <TimeClassExample>(nameof(ShouldSaveClassWithTime));
            var dynamicStorage = MongoTestHelpers.GetStorageProvider(nameof(ShouldSaveClassWithTime));

            // When

            classStorage.InsertOne(instance);

            var classInstance   = classStorage.Find().FirstOrDefault();
            var dynamicInstance = dynamicStorage.Find().FirstOrDefault();

            // Then

            Assert.IsNotNull(classInstance);
            Assert.AreEqual(time1, classInstance.TimeProperty);
            Assert.AreEqual(time2, classInstance.NullableTimeProperty);
            Assert.IsNotNull(classInstance.ComplexProperty);
            Assert.AreEqual(time3, classInstance.ComplexProperty.TimeProperty);
            Assert.IsNull(classInstance.ComplexProperty.NullableTimeProperty);

            Assert.IsNotNull(dynamicInstance);
            Assert.AreEqual(time1.TotalSeconds, dynamicInstance["TimeProperty"]);
            Assert.AreEqual(time2.TotalSeconds, dynamicInstance["NullableTimeProperty"]);
            Assert.IsNotNull(dynamicInstance["ComplexProperty"]);
            Assert.AreEqual(time3.TotalSeconds, ((DynamicWrapper)dynamicInstance["ComplexProperty"])["TimeProperty"]);
            Assert.IsNull(((DynamicWrapper)dynamicInstance["ComplexProperty"])["NullableTimeProperty"]);
        }