-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathControllerExtensionsTests.cs
More file actions
47 lines (41 loc) · 1.44 KB
/
ControllerExtensionsTests.cs
File metadata and controls
47 lines (41 loc) · 1.44 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
using NUnit.Framework;
//
using TestStack.FluentMVCTesting.Tests.TestControllers;
namespace TestStack.FluentMVCTesting.Tests
{
[TestFixture]
class ControllerExtensionsShould
{
private ControllerExtensionsController _controller;
[SetUp]
public void Setup()
{
_controller = new ControllerExtensionsController();
}
[Test]
public void Give_controller_modelstate_errors()
{
_controller.WithModelErrors();
Assert.That(_controller.ModelState.IsValid, Is.False);
}
[Test]
public void Call_action()
{
_controller.WithCallTo(c => c.SomeAction());
Assert.That(_controller.SomeActionCalled);
}
[Test]
public void Call_child_action()
{
_controller.WithCallToChild(c => c.SomeChildAction());
Assert.That(_controller.SomeChildActionCalled);
}
[Test]
public void Throw_exception_for_child_action_call_to_non_child_action()
{
var exception = Assert.Throws<InvalidControllerActionException>(() => _controller.WithCallToChild(c => c.SomeAction()));
Assert.That(exception.Message, Is.EqualTo("Expected action SomeAction of controller ControllerExtensionsController to be a child action, but it didn't have the ChildActionOnly attribute."));
}
}
}