forked from DarthFubuMVC/fubumvc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
503 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Configuration> | ||
<SharedSolutionTemplateManager> | ||
<LiveTemplates> | ||
<Template uid="c7021f12-6126-43b0-9e05-5f94d617d1e1" shortcut="pvt" description="New test case" text="[Test]
public void $TESTNAME$()
{
 $END$
}" reformat="True" shortenQualifiedReferences="True"> | ||
<Context> | ||
<CSharpContext context="TypeMember" minimumLanguageVersion="2.0" /> | ||
</Context> | ||
<Categories /> | ||
<Variables> | ||
<Variable name="TESTNAME" expression="" initialRange="0" /> | ||
</Variables> | ||
<CustomProperties /> | ||
</Template> | ||
</LiveTemplates> | ||
</SharedSolutionTemplateManager> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/FubuMVC.Core/Registration/Conventions/UrlRegistryCategoryConvention.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using FubuCore.Reflection; | ||
|
||
namespace FubuMVC.Core.Registration.Conventions | ||
{ | ||
public class UrlRegistryCategoryConvention : IConfigurationAction | ||
{ | ||
public void Configure(BehaviorGraph graph) | ||
{ | ||
graph.Actions().Each(a => | ||
{ | ||
a.HandlerType.ForAttribute<UrlRegistryCategoryAttribute>(att => a.ParentChain().Route.Category = att.Category); | ||
a.Method.ForAttribute<UrlRegistryCategoryAttribute>(att => a.ParentChain().Route.Category = att.Category); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/FubuMVC.Tests/Registration/Conventions/UrlRegistryCategoryConventionTester.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using FubuMVC.Core; | ||
using FubuMVC.Core.Registration; | ||
using FubuMVC.Core.Registration.Conventions; | ||
using FubuMVC.Core.Urls; | ||
using NUnit.Framework; | ||
|
||
namespace FubuMVC.Tests.Registration.Conventions | ||
{ | ||
[TestFixture] | ||
public class UrlRegistryCategoryConventionTester | ||
{ | ||
#region Setup/Teardown | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
graph = new FubuRegistry(x => | ||
{ | ||
x.Applies.ToThisAssembly(); | ||
x.Actions.IncludeTypesNamed(n => n.StartsWith("UrlCategory")); | ||
}).BuildGraph(); | ||
|
||
|
||
} | ||
|
||
[Test] | ||
public void action_that_has_no_attribute_on_either_class_or_method_should_have_no_category() | ||
{ | ||
graph.BehaviorFor<UrlCategoryController3>(x => x.Go()).Route.Category.ShouldBeNull(); | ||
graph.BehaviorFor<UrlCategoryController3>(x => x.Comeback()).Route.Category.ShouldBeNull(); | ||
|
||
} | ||
|
||
[Test] | ||
public void class_attribute_sets_the_category_if_there_is_no_method_level_attribute() | ||
{ | ||
graph.BehaviorFor<UrlCategoryController1>(x => x.Go()).Route.Category.ShouldEqual("admin"); | ||
} | ||
|
||
[Test] | ||
public void method_attribute_has_precedence_over_class_attribute() | ||
{ | ||
graph.BehaviorFor<UrlCategoryController1>(x => x.Comeback()).Route.Category.ShouldEqual("public"); | ||
} | ||
|
||
[Test] | ||
public void method_attribute_without_class_attribute() | ||
{ | ||
graph.BehaviorFor<UrlCategoryController2>(x => x.DecoratedMethod()).Route.Category.ShouldEqual("public"); | ||
} | ||
|
||
#endregion | ||
|
||
private BehaviorGraph graph; | ||
} | ||
|
||
|
||
|
||
[UrlRegistryCategory("admin")] | ||
public class UrlCategoryController1 | ||
{ | ||
public void Go() | ||
{ | ||
} | ||
|
||
[UrlRegistryCategory("public")] | ||
public void Comeback() | ||
{ | ||
} | ||
} | ||
|
||
public class UrlCategoryController2 | ||
{ | ||
public void Go() | ||
{ | ||
} | ||
|
||
[UrlRegistryCategory("public")] | ||
public void DecoratedMethod() | ||
{ | ||
} | ||
} | ||
|
||
public class UrlCategoryController3 | ||
{ | ||
public void Go() | ||
{ | ||
} | ||
|
||
public void Comeback() | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.