-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathControllerResultTest.cs
More file actions
29 lines (24 loc) · 1.06 KB
/
ControllerResultTest.cs
File metadata and controls
29 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.Web.Mvc;
namespace TestStack.FluentMVCTesting
{
public partial class ControllerResultTest<T> where T : Controller
{
public T Controller { get; }
public string ActionName { get; }
public ActionResult ActionResult { get; }
public void ValidateActionReturnType<TActionResult>() where TActionResult : ActionResult
{
var castedActionResult = ActionResult as TActionResult;
if (ActionResult == null)
throw new ActionResultAssertionException($"Received null action result when expecting {typeof(TActionResult).Name}.");
if (castedActionResult == null)
throw new ActionResultAssertionException($"Expected action result to be a {typeof(TActionResult).Name}, but instead received a {ActionResult.GetType().Name}.");
}
public ControllerResultTest(T controller, string actionName, ActionResult actionResult)
{
Controller = controller;
ActionName = actionName;
ActionResult = actionResult;
}
}
}