Skip to content

Commit fb9cd60

Browse files
committed
Recreated ViewResultAssertions in AspNetCore
Again, since ViewResultBase doesn't exist anymore, we need two different classes for both ViewResultAssertions and PartialViewResultAssertions. I had created it as a generic class (not understanding the reason for the generic at the beginning) and now saw that it has no use, so I removed it.
1 parent ed576c9 commit fb9cd60

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/FluentAssertions.AspNetCore.Mvc/PartialViewResultAssertions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using FluentAssertions.Primitives;
55
using Microsoft.AspNetCore.Mvc;
66

7-
namespace FluentAssertions.AspNetCore.Mvc
7+
namespace FluentAssertions.Mvc
88
{
99
public class PartialViewResultAssertions : ObjectAssertions
1010
{

src/FluentAssertions.AspNetCore.Mvc/ViewResultAssertions.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
using System;
22
using System.Diagnostics;
33
using FluentAssertions.Execution;
4-
using FluentAssertions.Mvc;
54
using FluentAssertions.Primitives;
65
using Microsoft.AspNetCore.Mvc;
76

8-
namespace FluentAssertions.AspNetCore.Mvc
7+
namespace FluentAssertions.Mvc
98
{
109
/// <summary>
1110
/// Contains a number of methods to assert that a <see cref="ViewResult" /> is in the expected state.
1211
/// </summary>
1312
[DebuggerNonUserCode]
14-
public class ViewResultAssertions<T> : ObjectAssertions
15-
where T : ViewResult
13+
public class ViewResultAssertions : ObjectAssertions
1614
{
1715
/// <summary>
1816
/// Initializes a new instance of the <see cref="T:ViewResultAssertions" /> class.
1917
/// </summary>
2018
/// <param name="subject">The object to test assertion on</param>
21-
public ViewResultAssertions(T subject) : base(subject)
19+
public ViewResultAssertions(ViewResult subject) : base(subject)
2220
{
2321
}
2422

25-
private T ViewResultSubject => (T) Subject;
23+
private ViewResult ViewResultSubject => (ViewResult) Subject;
2624

2725
/// <summary>
2826
/// The model.
@@ -40,7 +38,7 @@ public ViewResultAssertions(T subject) : base(subject)
4038
/// <param name="reasonArgs">
4139
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
4240
/// </param>
43-
public ViewResultAssertions<T> WithViewName(string expectedViewName, string reason = "",
41+
public ViewResultAssertions WithViewName(string expectedViewName, string reason = "",
4442
params object[] reasonArgs)
4543
{
4644
var actualViewName = ViewResultSubject.ViewName;
@@ -64,7 +62,7 @@ public ViewResultAssertions<T> WithViewName(string expectedViewName, string reas
6462
/// <param name="reasonArgs">
6563
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
6664
/// </param>
67-
public ViewResultAssertions<T> WithViewData(string key, object expectedValue, string reason = "",
65+
public ViewResultAssertions WithViewData(string key, object expectedValue, string reason = "",
6866
params object[] reasonArgs)
6967
{
7068
var actualViewData = ViewResultSubject.ViewData;
@@ -96,7 +94,7 @@ public ViewResultAssertions<T> WithViewData(string key, object expectedValue, st
9694
/// <param name="reasonArgs">
9795
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
9896
/// </param>
99-
public ViewResultAssertions<T> WithTempData(string key, object expectedValue, string reason = "",
97+
public ViewResultAssertions WithTempData(string key, object expectedValue, string reason = "",
10098
params object[] reasonArgs)
10199
{
102100
var actualTempData = ViewResultSubject.TempData;
@@ -140,7 +138,7 @@ public TModel ModelAs<TModel>()
140138
/// <param name="reasonArgs">
141139
/// Zero or more objects to format using the placeholders in <see cref="reason" />.
142140
/// </param>
143-
public ViewResultAssertions<T> WithDefaultViewName(string reason = "", params object[] reasonArgs)
141+
public ViewResultAssertions WithDefaultViewName(string reason = "", params object[] reasonArgs)
144142
{
145143
var viewName = ViewResultSubject.ViewName;
146144

src/FluentAssertions.Mvc.Shared/ViewResultAssertions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !NETSTANDARD1_6
12
using FluentAssertions.Execution;
23
using System;
34
using System.Web.Mvc;
@@ -39,3 +40,4 @@ public ViewResultAssertions WithMasterName(string expectedMasterName, string rea
3940
}
4041
}
4142
}
43+
#endif

0 commit comments

Comments
 (0)