public void Write_DBNull_ShouldReturnNullValue() { var options = new JsonSerializerOptions(); var converter = new DBNullConverter(); MemoryStream memoryStream; using (memoryStream = new MemoryStream()) using (var writer = new Utf8JsonWriter(memoryStream)) { converter.Write(writer, DBNull.Value, options); } var actual = Encoding.UTF8.GetString(memoryStream.ToArray()); Assert.Equal("null", actual); }
public void Write_Null_ShouldReturnNullValue() { var options = new JsonSerializerOptions(); var converter = new DBNullConverter(); MemoryStream memoryStream; using (memoryStream = new MemoryStream()) using (var writer = new Utf8JsonWriter(memoryStream)) { #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. converter.Write(writer, null, options); #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. } var actual = Encoding.UTF8.GetString(memoryStream.ToArray()); Assert.Equal("null", actual); }