Пример #1
0
        public void IsNullOrEmptyReturnsTrueWhenInstanceWritesTimeSpanPropertyWithNullValue()
        {
            var writer       = new TestableJsonWriter(null);
            var serializable = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", (TimeSpan?)null)
            };

            Assert.True(writer.IsNullOrEmpty(serializable));
        }
Пример #2
0
        public void IsNullOrEmptyReturnsTrueWhenInstanceWritesStringPropertyWithEmptyValue()
        {
            var writer       = new TestableJsonWriter(null);
            var serializable = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", string.Empty)
            };

            Assert.True(writer.IsNullOrEmpty(serializable));
        }
Пример #3
0
        public void IsNullOrEmptyReturnsFalseWhenInstanceWritesDateTimeOffsetProperty()
        {
            var writer       = new TestableJsonWriter(null);
            var serializable = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", DateTimeOffset.UtcNow)
            };

            Assert.False(writer.IsNullOrEmpty(serializable));
        }
Пример #4
0
        public void IsNullOrEmptyReturnsTrueWhenInstanceWritesRawObjectValueWithNullValue()
        {
            var writer       = new TestableJsonWriter(null);
            var serializable = new StubIJsonSerializable {
                OnSerialize = w => w.WriteRawValue(null)
            };

            Assert.True(writer.IsNullOrEmpty(serializable));
        }
Пример #5
0
        public void IsNullOrEmptyReturnsTrueWhenInstanceWritesIJsonSerializablePropertyWithNullValue()
        {
            var writer = new TestableJsonWriter(null);
            var parent = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("child", (IJsonSerializable)null)
            };

            Assert.True(writer.IsNullOrEmpty(parent));
        }
Пример #6
0
        public void IsNullOrEmptyReturnsFalseWhenInstanceWritesTimeSpanProperty()
        {
            var writer       = new TestableJsonWriter(null);
            var serializable = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", TimeSpan.FromSeconds(0.0))
            };

            Assert.False(writer.IsNullOrEmpty(serializable));
        }
Пример #7
0
        public void IsNullOrEmptyReturnsFalseWhenInstanceWritesStringProperty()
        {
            var writer       = new TestableJsonWriter(null);
            var serializable = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", "value")
            };

            Assert.False(writer.IsNullOrEmpty(serializable));
        }
Пример #8
0
        public void IsNullOrEmptyReturnsTrueWhenInstanceWritesIDictionaryStringStringWithNullValue()
        {
            var writer   = new TestableJsonWriter(null);
            var instance = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", (IDictionary <string, string>)null)
            };

            Assert.True(writer.IsNullOrEmpty(instance));
        }
Пример #9
0
 public void WritePropertyIJsonSerializableWritesPropertyName()
 {
     using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
     {
         var serializable = new StubIJsonSerializable {
             OnSerialize = w => w.WriteProperty("child", "property")
         };
         new JsonWriter(stringWriter).WriteProperty("name", serializable);
         AssertEx.StartsWith("\"name\":", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase);
     }
 }
Пример #10
0
        public void IsNullOrEmptyReturnsFalseWhenInstanceWritesIDictionaryStringStringProperty()
        {
            var writer   = new TestableJsonWriter(null);
            var instance = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", new Dictionary <string, string> {
                    { "name", "value" }
                })
            };

            Assert.False(writer.IsNullOrEmpty(instance));
        }
Пример #11
0
 public void WritePropertyIJsonSerializableInvokesSerialize()
 {
     using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
     {
         bool serializeInvoked          = false;
         IJsonSerializable serializable = new StubIJsonSerializable {
             OnSerialize = w => serializeInvoked = true
         };
         new JsonWriter(stringWriter).WriteProperty("name", serializable);
         Assert.True(serializeInvoked);
     }
 }
Пример #12
0
        public void IsNullOrEmptyReturnsFalseWhenInstanceWritesIJsonSerializableProperty()
        {
            var writer = new TestableJsonWriter(null);
            var child  = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("name", "value")
            };
            var parent = new StubIJsonSerializable {
                OnSerialize = w => w.WriteProperty("child", child)
            };

            Assert.False(writer.IsNullOrEmpty(parent));
        }
 public void WritePropertyIJsonSerializableWritesPropertyName()
 {
     using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
     {
         var serializable = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("child", "property") };
         new JsonWriter(stringWriter).WriteProperty("name", serializable);
         AssertEx.StartsWith("\"name\":", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase);
     }
 }
 public void IsNullOrEmptyReturnsTrueWhenInstanceWritesRawObjectValueWithNullValue()
 {
     var writer = new TestableJsonWriter(null);
     var serializable = new StubIJsonSerializable { OnSerialize = w => w.WriteRawValue(null) };
     Assert.True(writer.IsNullOrEmpty(serializable));
 }
 public void IsNullOrEmptyReturnsFalseWhenInstanceWritesIDictionaryStringStringProperty()
 {
     var writer = new TestableJsonWriter(null);
     var instance = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", new Dictionary<string, string> { { "name", "value" } }) };
     Assert.False(writer.IsNullOrEmpty(instance));
 }
 public void IsNullOrEmptyReturnsTrueWhenInstanceWritesIDictionaryStringStringWithNullValue()
 {
     var writer = new TestableJsonWriter(null);
     var instance = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", (IDictionary<string, string>)null) };
     Assert.True(writer.IsNullOrEmpty(instance));
 }
 public void IsNullOrEmptyReturnsTrueWhenInstanceWritesIJsonSerializablePropertyWithEmptyValue()
 {
     var writer = new TestableJsonWriter(null);
     var child = new StubIJsonSerializable();
     var parent = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", child) };
     Assert.True(writer.IsNullOrEmpty(parent));
 }
 public void IsNullOrEmptyReturnsTrueWhenInstanceWritesBoolPropertyWithNullValue()
 {
     var writer = new TestableJsonWriter(null);
     var serializable = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", (bool?)null) };
     Assert.True(writer.IsNullOrEmpty(serializable));
 }
 public void IsNullOrEmptyReturnsFalseWhenInstanceWritesStringProperty()
 {
     var writer = new TestableJsonWriter(null);
     var serializable = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", "value") };
     Assert.False(writer.IsNullOrEmpty(serializable));
 }
 public void WritePropertyIJsonSerializableInvokesSerialize()
 {
     using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
     {
         bool serializeInvoked = false;
         IJsonSerializable serializable = new StubIJsonSerializable { OnSerialize = w => serializeInvoked = true };
         new JsonWriter(stringWriter).WriteProperty("name", serializable);
         Assert.True(serializeInvoked);
     }
 }
 public void IsNullOrEmptyReturnsFalseWhenInstanceWritesTimeSpanProperty()
 {
     var writer = new TestableJsonWriter(null);
     var serializable = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", TimeSpan.FromSeconds(0.0)) };
     Assert.False(writer.IsNullOrEmpty(serializable));
 }
 public void IsNullOrEmptyReturnsFalseWhenInstanceWritesDateTimeOffsetProperty()
 {
     var writer = new TestableJsonWriter(null);
     var serializable = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", DateTimeOffset.UtcNow) };
     Assert.False(writer.IsNullOrEmpty(serializable));
 }
 public void IsNullOrEmptyReturnsFalseWhenInstanceWritesIJsonSerializableProperty()
 {
     var writer = new TestableJsonWriter(null);
     var child = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("name", "value") };
     var parent = new StubIJsonSerializable { OnSerialize = w => w.WriteProperty("child", child) };
     Assert.False(writer.IsNullOrEmpty(parent));
 }