Permalink
Browse files

- Added additional spec for Load method of LazySecurityPolicy.

  • Loading branch information...
1 parent d417ddb commit f360bc87fb8036e6af1b78ee537e5db492db6b2b Kristoffer Ahl committed Dec 4, 2012
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using FluentSecurity.Policy;
using FluentSecurity.Policy.Contexts;
using FluentSecurity.Specification.Helpers;
@@ -84,6 +85,20 @@ public void Should_return_null_when_loading_policy_with_constructor_arguments()
// Assert
Assert.That(policy, Is.Null);
}
+
+ [Test]
+ public void Should_return_null_when_no_policy_is_returned_by_service_locator()
+ {
+ // Arrange
+ SecurityConfigurator.Configure(configuration => configuration.ResolveServicesUsing(t => Enumerable.Empty<object>()));
+ var lazySecurityPolicy = new LazySecurityPolicy<PolicyWithConstructorArguments>();
+
+ // Act
+ var policy = lazySecurityPolicy.Load();
+
+ // Assert
+ Assert.That(policy, Is.Null);
+ }
}
[TestFixture]
@@ -20,8 +20,8 @@ public ISecurityPolicy Load()
}
return PolicyType.HasEmptyConstructor()
- ? (ISecurityPolicy)Activator.CreateInstance<TSecurityPolicy>()
- : null;
+ ? (ISecurityPolicy)Activator.CreateInstance<TSecurityPolicy>()
+ : null;
}
public PolicyResult Enforce(ISecurityContext context)

0 comments on commit f360bc8

Please sign in to comment.