public void Should_have_default_policy_cache_lifecycle_set_to_PerHttpRequest()
        {
            // Arrange
            var advancedConfiguration = new AdvancedConfiguration();

            // Act
            advancedConfiguration.SetDefaultResultsCacheLifecycle(Cache.PerHttpRequest);

            // Assert
            Assert.That(advancedConfiguration.DefaultResultsCacheLifecycle, Is.EqualTo(Cache.PerHttpRequest));
        }
        public void Should_ignore_missing_configurations()
        {
            // Arrange
            var model = new SecurityRuntime();
            var advancedConfiguration = new AdvancedConfiguration(model);

            // Act
            advancedConfiguration.IgnoreMissingConfiguration();

            // Assert
            Assert.That(model.ShouldIgnoreMissingConfiguration, Is.True);
        }
 public void SetUp()
 {
     _advancedConfiguration = new AdvancedConfiguration();
 }
        public void Should_add_convention()
        {
            // Arrange
            var model = new SecurityRuntime();
            var advancedConfiguration = new AdvancedConfiguration(model);
            var expectedConvention = new MockConvention();

            // Act
            advancedConfiguration.Conventions(conventions => conventions.Add(expectedConvention));

            // Assert
            Assert.That(model.Conventions.Contains(expectedConvention), Is.True);
        }
 public void SetUp()
 {
     _runtime = new SecurityRuntime();
     _advancedConfiguration = new AdvancedConfiguration(_runtime);
 }
        public void Should_have_default_policy_cache_lifecycle_set_to_PerHttpSession()
        {
            // Arrange
            var model = new SecurityRuntime();
            var advancedConfiguration = new AdvancedConfiguration(model);

            // Act
            advancedConfiguration.SetDefaultResultsCacheLifecycle(Cache.PerHttpSession);

            // Assert
            Assert.That(model.DefaultResultsCacheLifecycle, Is.EqualTo(Cache.PerHttpSession));
        }
        public void Should_throw_when_action_is_null()
        {
            // Arrange
            var model = new SecurityRuntime();
            var advancedConfiguration = new AdvancedConfiguration(model);

            // Act & Assert
            Assert.Throws<ArgumentNullException>(() => advancedConfiguration.Conventions(null));
        }
        public void Should_remove_matching_convention()
        {
            // Arrange
            var model = new SecurityRuntime();
            var advancedConfiguration = new AdvancedConfiguration(model);
            Assert.That(model.Conventions.Any(c => c is FindByPolicyNameConvention), Is.True);

            // Act
            advancedConfiguration.Conventions(conventions => conventions.RemoveAll(c => c is FindByPolicyNameConvention));

            // Assert
            Assert.That(model.Conventions.Any(c => c is FindByPolicyNameConvention), Is.False);
        }
        public void Should_remove_convention()
        {
            // Arrange
            var model = new SecurityRuntime();
            var advancedConfiguration = new AdvancedConfiguration(model);
            var convention = new MockConvention();
            advancedConfiguration.Conventions(conventions => conventions.Add(convention));
            Assert.That(model.Conventions.Contains(convention), Is.True);

            // Act
            advancedConfiguration.Conventions(conventions => conventions.Remove(convention));

            // Assert
            Assert.That(model.Conventions.Contains(convention), Is.False);
        }