Skip to content

Commit 297b9ce

Browse files
committed
Modify type message checks.
1 parent 7fef170 commit 297b9ce

7 files changed

+17
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void ValueAs_GivenWrongType_ShouldFail()
123123
public void ValueAs_Null_ShouldFail()
124124
{
125125
ActionResult result = new CreatedAtActionResult(string.Empty, string.Empty, null, null);
126-
var failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull("CreatedAtActionResult.Value", typeof(object).FullName);
126+
var failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull("CreatedAtActionResult.Value", typeof(object));
127127

128128
Action a = () => result.Should().BeCreatedAtActionResult().ValueAs<object>();
129129

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void ValueAs_GivenExpectedValue_ShouldPass()
8383
public void ValueAs_Null_ShouldFail()
8484
{
8585
ActionResult result = new CreatedAtRouteResult(string.Empty, null, null);
86-
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull("CreatedAtRouteResult.Value", typeof(object).FullName);
86+
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull("CreatedAtRouteResult.Value", typeof(object));
8787

8888
Action a = () => result.Should().BeCreatedAtRouteResult().ValueAs<object>();
8989

@@ -95,7 +95,7 @@ public void ValueAs_GivenWrongType_ShouldFail()
9595
{
9696
ActionResult result = new CreatedAtRouteResult(string.Empty, null, "");
9797
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundY(
98-
"CreatedAtRouteResult.Value", typeof(int).FullName, typeof(string).FullName);
98+
"CreatedAtRouteResult.Value", typeof(int), typeof(string));
9999

100100
Action a = () => result.Should().BeCreatedAtRouteResult().ValueAs<int>().Should().Be(2);
101101

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void ValueAs_GivenUnexpectedValue_ShouldFail()
4747
public void ValueAs_GivenWrongType_ShouldFail()
4848
{
4949
var result = new TestController().Created(TestUri, TestValue);
50-
var failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundY("CreatedResult.Value", typeof(int).FullName, typeof(string).FullName);
50+
var failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundY("CreatedResult.Value", typeof(int), typeof(string));
5151

5252
Action a = () => result.Should().BeCreatedResult().ValueAs<int>().Should().Be(2, Reason, ReasonArgs);
5353

@@ -58,7 +58,7 @@ public void ValueAs_GivenWrongType_ShouldFail()
5858
public void ValueAs_Null_ShouldFail()
5959
{
6060
ActionResult result = new CreatedResult(TestUri, null);
61-
var failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull("CreatedResult.Value", typeof(object).FullName);
61+
var failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull("CreatedResult.Value", typeof(object));
6262

6363
Action a = () => result.Should().BeCreatedResult().ValueAs<object>();
6464

tests/FluentAssertions.AspNetCore.Mvc.Tests/Helpers/FailureMessageHelper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public static string ExpectedKeyButNotFound(string context, string key, string e
4646
return $"Expected {context} to contain value \"{expected}\" at key \"{key}\" because it is 10, but the key was not found.";
4747
}
4848

49-
internal static string ExpectedContextTypeXButFoundY(string context, string expected, string actual)
50-
{
51-
return $"Expected {context} to be of type {expected} but was {actual}.";
52-
}
53-
5449
private static object ToString(DateTimeOffset? expected)
5550
{
5651
if (expected.HasValue)
@@ -74,7 +69,12 @@ private static object ToString(DateTimeOffset? expected)
7469
return "<null>";
7570
}
7671

77-
internal static string ExpectedContextTypeXButFoundNull(string context, string expectedType)
72+
internal static string ExpectedContextTypeXButFoundY(string context, Type expected, Type actual)
73+
{
74+
return $"Expected {context} to be of type {expected.FullName} but was {actual.FullName}.";
75+
}
76+
77+
internal static string ExpectedContextTypeXButFoundNull(string context, Type expectedType)
7878
{
7979
return $"Expected {context} to be of type {expectedType}, but no value was supplied.";
8080
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void ValueAs_GivenWrongType_ShouldFail()
8787
{
8888
var result = new TestController().JsonSimpleValue();
8989
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundY(
90-
"JsonResult.Value", typeof(int).FullName, typeof(string).FullName);
90+
"JsonResult.Value", typeof(int), typeof(string));
9191

9292
Action a = () => result.Should().BeJsonResult().ValueAs<int>().Should().Be(2);
9393

@@ -100,7 +100,7 @@ public void ValueAs_Null_ShouldFail()
100100
{
101101
ActionResult result = new JsonResult(null);
102102
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull(
103-
"JsonResult.Value", typeof(object).FullName);
103+
"JsonResult.Value", typeof(object));
104104

105105
Action a = () => result.Should().BeJsonResult().ValueAs<object>();
106106

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void ValueAs_GivenWrongType_ShouldFail()
4646
{
4747
var result = new TestController().NotFound(TestValue);
4848
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundY(
49-
"NotFoundObjectResult.Value", typeof(int).FullName, typeof(string).FullName);
49+
"NotFoundObjectResult.Value", typeof(int), typeof(string));
5050

5151
Action a = () => result.Should().BeNotFoundObjectResult().ValueAs<int>().Should().Be(2);
5252

@@ -59,7 +59,7 @@ public void ValueAs_Null_ShouldFail()
5959
{
6060
ActionResult result = new NotFoundObjectResult(null);
6161
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull(
62-
"NotFoundObjectResult.Value", typeof(object).FullName);
62+
"NotFoundObjectResult.Value", typeof(object));
6363

6464
Action a = () => result.Should().BeNotFoundObjectResult().ValueAs<object>();
6565

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void ValueAs_GivenWrongType_ShouldFail()
4848
{
4949
var result = new TestController().Ok(TestValue);
5050
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundY(
51-
"OkObjectResult.Value", typeof(int).FullName, typeof(string).FullName);
51+
"OkObjectResult.Value", typeof(int), typeof(string));
5252

5353
Action a = () => result.Should().BeOkObjectResult().ValueAs<int>().Should().Be(2);
5454

@@ -61,7 +61,7 @@ public void ValueAs_Null_ShouldFail()
6161
{
6262
ActionResult result = new OkObjectResult(null);
6363
string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull(
64-
"OkObjectResult.Value", typeof(object).FullName);
64+
"OkObjectResult.Value", typeof(object));
6565

6666
Action a = () => result.Should().BeOkObjectResult().ValueAs<object>();
6767

0 commit comments

Comments
 (0)