forked from DarthFubuMVC/fubumvc
/
ActionLessViewRegistrationTester.cs
77 lines (63 loc) · 2.62 KB
/
ActionLessViewRegistrationTester.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using FubuMVC.Core;
using FubuMVC.Core.Registration;
using FubuMVC.Core.Registration.Routes;
using FubuMVC.Core.View;
using FubuMVC.Tests.Urls;
using FubuMVC.WebForms;
using FubuTestingSupport;
using NUnit.Framework;
namespace FubuMVC.Tests.Registration.Expressions
{
[TestFixture]
public class ActionLessViewRegistrationTester
{
private BehaviorGraph theBehaviorGraph;
[SetUp]
public void SetUp()
{
var registry = new FubuRegistry();
registry.Import<WebFormsEngine>();
registry.Views.RegisterActionLessViews(token => token.ViewType.Name.StartsWith("FakeView"), chain => chain.IsPartialOnly = true);
theBehaviorGraph = registry.BuildGraph();
}
[Test]
public void should_have_a_chain_for_each_matching_view()
{
theBehaviorGraph.BehaviorFor(typeof (InputModel)).ShouldNotBeNull();
theBehaviorGraph.BehaviorFor(typeof (TestInputModel)).ShouldNotBeNull();
theBehaviorGraph.BehaviorFor(typeof (Model1)).ShouldNotBeNull();
theBehaviorGraph.BehaviorFor(typeof (Model3)).ShouldNotBeNull();
}
[Test]
public void all_behavior_chains_for_the_action_less_views_should_be_marked_as_partial_only()
{
theBehaviorGraph.BehaviorFor(typeof(InputModel)).IsPartialOnly.ShouldBeTrue();
theBehaviorGraph.BehaviorFor(typeof(TestInputModel)).IsPartialOnly.ShouldBeTrue();
theBehaviorGraph.BehaviorFor(typeof(Model1)).IsPartialOnly.ShouldBeTrue();
theBehaviorGraph.BehaviorFor(typeof(Model3)).IsPartialOnly.ShouldBeTrue();
}
}
[TestFixture]
public class ActionLessViewRegistrationWithIViewToken
{
private BehaviorGraph theBehaviorGraph;
[SetUp]
public void SetUp()
{
var registry = new FubuRegistry();
registry.Import<WebFormsEngine>();
registry.Views.RegisterActionLessViews(token => token.ViewType.Name.StartsWith("FakeView"), (chain, token) => chain.Route = new RouteDefinition(token.Name));
theBehaviorGraph = registry.BuildGraph();
}
[Test]
public void chain_is_configured_depending_on_token()
{
var behavior = theBehaviorGraph.BehaviorFor(typeof (InputModel));
behavior.Route.Pattern.ShouldEqual(typeof (FakeView1).Name);
}
}
public class FakeView1 : FubuPage<InputModel>{}
public class FakeView2 : FubuPage<TestInputModel> { }
public class FakeView3 : FubuPage<Model1> { }
public class FakeView4 : FubuPage<Model3> { }
}