Skip to content

Commit 56cfb3c

Browse files
committed
Add SerializerSettings to JsonResult.
1 parent 2c745ae commit 56cfb3c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/FluentAssertions.AspNetCore.Mvc/JsonResultAssertions.cs

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FluentAssertions.Execution;
22
using FluentAssertions.Primitives;
33
using Microsoft.AspNetCore.Mvc;
4+
using Newtonsoft.Json;
45
using System;
56
using System.Diagnostics;
67

@@ -27,6 +28,11 @@ public JsonResultAssertions(JsonResult subject) : base(subject)
2728

2829
#region Public Properties
2930

31+
/// <summary>
32+
/// The serializer settings of the JsonResult.
33+
/// </summary>
34+
public JsonSerializerSettings SerializerSettings => JsonResultSubject.SerializerSettings;
35+
3036
/// <summary>
3137
/// The value on the JsonResult
3238
/// </summary>

tests/FluentAssertions.AspNetCore.Mvc.Tests/JsonResultAssertions_Tests.cs

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using FluentAssertions.Mvc.Tests.Helpers;
22
using Microsoft.AspNetCore.Mvc;
3+
using Newtonsoft.Json;
34
using System;
45
using Xunit;
56

@@ -90,5 +91,13 @@ public void ValueAs_Null_ShouldFail()
9091
.WithMessage(failureMessage);
9192
}
9293

94+
[Fact]
95+
public void SerializerSettings_GivenExpectedValue_ShouldPass()
96+
{
97+
var expectedValue = new JsonSerializerSettings();
98+
var result = new JsonResult("value", expectedValue);
99+
100+
result.Should().BeJsonResult().SerializerSettings.Should().BeSameAs(expectedValue);
101+
}
93102
}
94103
}

0 commit comments

Comments
 (0)