public void AdaptedJsonReader_Holds_Serializer_Properties() { var serializer = CustomJson.Serializer(); using (var jsonReader = serializer.AdaptedJsonReader(TextReader.Null)) { Assert.True(ReferenceEquals(jsonReader.Culture, serializer.Culture)); Assert.True(jsonReader.DateParseHandling.Equals(serializer.DateParseHandling)); Assert.True(jsonReader.DateFormatString.Equals(serializer.DateFormatString)); Assert.True(jsonReader.DateTimeZoneHandling.Equals(serializer.DateTimeZoneHandling)); Assert.True(jsonReader.FloatParseHandling.Equals(serializer.FloatParseHandling)); Assert.True(jsonReader.MaxDepth.Equals(serializer.MaxDepth)); Assert.True(jsonReader.CloseInput); } }
public void AdaptedJsonWriter_Holds_Serializer_Properties() { var serializer = CustomJson.Serializer(); using (var jsonWriter = serializer.AdaptedJsonWriter(TextWriter.Null)) { Assert.True(ReferenceEquals(jsonWriter.Culture, serializer.Culture)); Assert.True(jsonWriter.DateFormatHandling.Equals(serializer.DateFormatHandling)); Assert.True(jsonWriter.DateFormatString.Equals(serializer.DateFormatString)); Assert.True(jsonWriter.DateTimeZoneHandling.Equals(serializer.DateTimeZoneHandling)); Assert.True(jsonWriter.FloatFormatHandling.Equals(serializer.FloatFormatHandling)); Assert.True(jsonWriter.Formatting.Equals(serializer.Formatting)); Assert.True(jsonWriter.StringEscapeHandling.Equals(serializer.StringEscapeHandling)); Assert.True(jsonWriter.CloseOutput); } }
public void FromJsonGetNext_Works_As_Expected() { var data = "20.45"; using (var jsonReader = data.CreateJsonReader()) { Assert.True(jsonReader.Read()); Assert.True(jsonReader.FromJsonGetNext <double>(CustomJson.Serializer()).Equals(20.45)); } data = JsonConvert.SerializeObject(new TestClass { Name = "Testing" }); using (var jsonReader = data.CreateJsonReader()) { Assert.True(jsonReader.Read()); Assert.True(jsonReader.FromJsonGetNext <TestClass>(CustomJson.Serializer()).Name.Equals("Testing")); } }
public void Serializer_Returns_A_New_Instance_Everytime_With_Consistent_Properties() { var first = CustomJson.Serializer(); Assert.False(ReferenceEquals(first, CustomJson.Serializer())); Assert.False(first.CheckAdditionalContent); Assert.True(first.Culture.Equals(CultureInfo.CurrentCulture)); Assert.True(first.DateFormatHandling.Equals(DateFormatHandling.IsoDateFormat)); Assert.True(first.DateTimeZoneHandling.Equals(DateTimeZoneHandling.Utc)); Assert.True(first.FloatFormatHandling.Equals(FloatFormatHandling.DefaultValue)); Assert.True(first.Formatting.Equals(Formatting.None)); Assert.True(first.StringEscapeHandling.Equals(StringEscapeHandling.Default)); Assert.True(first.ConstructorHandling.Equals(ConstructorHandling.AllowNonPublicDefaultConstructor)); Assert.True(first.DateParseHandling.Equals(DateParseHandling.DateTime)); Assert.True(first.DefaultValueHandling.Equals(DefaultValueHandling.Ignore)); Assert.True(first.FloatParseHandling.Equals(FloatParseHandling.Double)); Assert.True(first.MissingMemberHandling.Equals(MissingMemberHandling.Ignore)); Assert.True(first.NullValueHandling.Equals(NullValueHandling.Ignore)); Assert.True(first.ObjectCreationHandling.Equals(ObjectCreationHandling.Auto)); Assert.True(first.PreserveReferencesHandling.Equals(PreserveReferencesHandling.None)); Assert.True(first.ReferenceLoopHandling.Equals(ReferenceLoopHandling.Error)); Assert.True(first.TypeNameAssemblyFormatHandling.Equals(TypeNameAssemblyFormatHandling.Simple)); Assert.True(first.TypeNameHandling.Equals(TypeNameHandling.Auto)); }