-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathControllerResultTest.cs
32 lines (27 loc) · 1.16 KB
/
ControllerResultTest.cs
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
30
31
32
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(string.Format("Received null action result when expecting {0}.",
typeof(TActionResult).Name));
if (castedActionResult == null)
throw new ActionResultAssertionException(string.Format("Expected action result to be a {0}, but instead received a {1}.",
typeof(TActionResult).Name,
ActionResult.GetType().Name));
}
public ControllerResultTest(T controller, string actionName, ActionResult actionResult)
{
Controller = controller;
ActionName = actionName;
ActionResult = actionResult;
}
}
}