Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
- Added additional spec for Load method of LazySecurityPolicy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristoffer Ahl committed Dec 4, 2012
1 parent d417ddb commit f360bc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions FluentSecurity.Specification/Policy/LazySecurityPolicySpec.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentSecurity.Policy;
using FluentSecurity.Policy.Contexts;
using FluentSecurity.Specification.Helpers;
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions FluentSecurity/Policy/LazySecurityPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f360bc8

Please sign in to comment.