Skip to content

Loading…

Update PoliciesExpression to Policy config type #489

Merged
merged 1 commit into from

2 participants

@smerrell
The FubuMVC Master Account member

Fixes the bug mentioned in the mailing list (https://groups.google.com/d/msg/fubumvc-devel/qb1Uy5ePyWQ/zNFxvYGuEhwJ) since @mkmurray was working on other things.

I don't really like my tests though so I'd love if it could get some attention from @jeremydmiller @jmarnold or @CoreyKaylor to help me think of a better way to do this.

@smerrell smerrell Update PoliciesExpression to Policy config type
* Add(IConfigurationAction action, string configurationType) and
  Add<T>(Action<T> configure, string configurationType) updated to
  default configurationType to Policy
* Per Jeremy's suggestion https://groups.google.com/d/msg/fubumvc-devel/qb1Uy5ePyWQ/zNFxvYGuEhwJ
6d05e34
@jeremydmiller jeremydmiller merged commit 10a6f80 into master
@jeremydmiller jeremydmiller deleted the policiesexpression-defaults branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 5, 2013
  1. @smerrell

    Update PoliciesExpression to Policy config type

    smerrell committed
    * Add(IConfigurationAction action, string configurationType) and
      Add<T>(Action<T> configure, string configurationType) updated to
      default configurationType to Policy
    * Per Jeremy's suggestion https://groups.google.com/d/msg/fubumvc-devel/qb1Uy5ePyWQ/zNFxvYGuEhwJ
View
8 src/FubuMVC.Core/Registration/DSL/PoliciesExpression.cs
@@ -45,15 +45,15 @@ public PoliciesExpression Reorder(Action<ReorderBehaviorsPolicy> configure)
var policy = new Policy();
policy.Wrap.WithBehavior<T>();
- Add(policy, ConfigurationType.Policy);
+ Add(policy);
}
public void Add<T>() where T : IConfigurationAction, new()
{
- Add(new T(), ConfigurationType.Policy);
+ Add(new T());
}
- public void Add<T>(Action<T> configure, string configurationType = null) where T : IConfigurationAction, new()
+ public void Add<T>(Action<T> configure, string configurationType = ConfigurationType.Policy) where T : IConfigurationAction, new()
{
var action = new T();
configure(action);
@@ -69,7 +69,7 @@ public void Add(Action<Policy> configuration, string configurationType = Configu
Add(policy, configurationType);
}
- public void Add(IConfigurationAction action, string configurationType = null)
+ public void Add(IConfigurationAction action, string configurationType = ConfigurationType.Policy)
{
_configuration.Add(action, configurationType);
}
View
40 src/FubuMVC.Tests/Registration/DSL/PoliciesExpressionTester.cs
@@ -80,6 +80,34 @@ public void move_behavior_before_authorization()
}
}
+ [TestFixture]
+ public class when_adding_an_iconfigurationaction_without_specifying_configuration_type
+ {
+ [Test]
+ public void it_should_default_to_policy()
+ {
+ FakePolicy.Count = 0;
+ BehaviorGraph.BuildFrom(graph =>
+ graph.Policies.Add(new FakePolicy()));
+
+ FakePolicy.Count.ShouldEqual(1);
+ }
+ }
+
+ [TestFixture]
+ public class when_adding_an_action_of_policy_without_specifying_configuration_type
+ {
+ [Test]
+ public void it_should_default_to_policy()
+ {
+ FakePolicy.Count = 0;
+ BehaviorGraph.BuildFrom(graph =>
+ graph.Policies.Add<FakePolicy>(x => x.NoOp()));
+
+ FakePolicy.Count.ShouldEqual(1);
+ }
+ }
+
public class OrderingPolicyController
{
[WrapWith(typeof(OPWrapper2), typeof(OPWrapper3))]
@@ -129,4 +157,16 @@ public void InvokePartial()
throw new NotImplementedException();
}
}
+
+ public class FakePolicy : IConfigurationAction
+ {
+ public static int Count;
+
+ public void Configure(BehaviorGraph graph)
+ {
+ Count++;
+ }
+
+ public void NoOp() { }
+ }
}
Something went wrong with that request. Please try again.