Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/Tests.All/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public static JsonSerializerOptions Options
NumberHandling = JsonNumberHandling.AllowReadingFromString
};

opt.Converters.Add(new MaybeJsonConverterFactory());
opt.Converters.Add(new MonadJsonConverterFactory());
opt.Converters.AddWrapConverters();
return opt;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Text.Json;

namespace Wrap.Json.Maybe_Tests;
namespace Wrap.Json.MaybeJsonConverter_Tests;

public class Deserialize_Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Text.Json;

namespace Wrap.Json.Maybe_Tests;
namespace Wrap.Json.MaybeJsonConverter_Tests;

public class Serialize_Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ public void Returns_Union_With_Value()
var value = Rnd.Str;
var json = $"\"{value}\"";
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json));
var opt = new JsonSerializerOptions();
var converter = new MonadJsonConverter<Test, string>();

// Act
var result = converter.Read(ref reader, typeof(Test), opt);
var result = converter.Read(ref reader, typeof(Test), new());

// Assert
var test = Assert.IsType<Test>(result);
Expand All @@ -42,14 +41,13 @@ public class With_Invalid_Json
public void Throws_NullMonadValueException(string input)
{
// Arrange
var opt = new JsonSerializerOptions();
var converter = new MonadJsonConverter<Test, string>();

// Act
var result = Record.Exception(() =>
{
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(input));
return converter.Read(ref reader, typeof(Test), opt);
return converter.Read(ref reader, typeof(Test), new());
});

// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Writes_Null_Values()
opt.Converters.AddWrapConverters();

// Act
var result = JsonSerializer.Serialize(obj, opt);
var result = JsonSerializer.Serialize(obj, Helpers.Json.Options);

// Assert
Assert.Equal(/*lang=json,strict*/ "{\"Foo\":null,\"Bar\":null,\"Gu\":null,\"When\":null}", result);
Expand All @@ -45,7 +45,7 @@ public void Writes_Json_Values()
opt.Converters.AddWrapConverters();

// Act
var result = JsonSerializer.Serialize(obj, opt);
var result = JsonSerializer.Serialize(obj, Helpers.Json.Options);

// Assert
Assert.Equal($"{{\"Foo\":{intVal},\"Bar\":\"{strVal}\",\"Gu\":\"{guidVal}\",\"When\":\"{dtVal:o}\"}}", result);
Expand Down