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));
        }
示例#2
0
        public void Should_have_default_policy_cache_lifecycle_set_to_DoNotCache()
        {
            // Arrange
            var advancedConfiguration = new AdvancedConfiguration();

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

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

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

            // Assert
            Assert.That(model.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);
        }
 internal ApplicationConfiguration()
 {
     this._extensibility    = new ExtensibilityConfiguration();
     this.IgnoreSslErrors   = true;
     this._customInstallers = new List <IWindsorInstaller>();
     this._database         = this.Register <DatabaseConfiguration>(() => new DatabaseConfiguration(this));
     this._tasks            = this.Register <TasksConfiguration>(() => new TasksConfiguration(this));
     this._logging          = this.Register <LoggingConfiguration>(() => new LoggingConfiguration(this));
     this._migration        = this.Register <MigrationConfiguration>(() => new MigrationConfiguration(this));
     this._hosts            = this.Register <HostsConfiguration>(() => new HostsConfiguration(this));
     this._advanced         = this.Register <AdvancedConfiguration>(() => new AdvancedConfiguration(this));
     this.Register <ApplicationConfiguration>(() => this);
 }
        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 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);
        }
示例#9
0
        /// <summary>
        /// Creates a serverless NServiceBus endpoint running within an AzureStorageQueue trigger.
        /// </summary>
        public StorageQueueTriggeredEndpointConfiguration(string endpointName, string connectionStringName = null)
        {
            EndpointConfiguration = new EndpointConfiguration(endpointName);

            EndpointConfiguration.Recoverability().Delayed(c => c.NumberOfRetries(0));

            recoverabilityPolicy.SendFailedMessagesToErrorQueue = true;
            EndpointConfiguration.Recoverability().CustomPolicy(recoverabilityPolicy.Invoke);

            // Disable diagnostics by default as it will fail to create the diagnostics file in the default path.
            // Can be overriden by ServerlessEndpointConfiguration.LogDiagnostics().
            EndpointConfiguration.CustomDiagnosticsWriter(_ => Task.CompletedTask);

            // 'WEBSITE_SITE_NAME' represents an Azure Function App and the environment variable is set when hosting the function in Azure.
            var functionAppName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? Environment.MachineName;

            EndpointConfiguration.UniquelyIdentifyRunningInstance()
            .UsingCustomDisplayName(functionAppName)
            .UsingCustomIdentifier(DeterministicGuid.Create(functionAppName));

            // Look for license as an environment variable
            var licenseText = Environment.GetEnvironmentVariable("NSERVICEBUS_LICENSE");

            if (!string.IsNullOrWhiteSpace(licenseText))
            {
                EndpointConfiguration.License(licenseText);
            }

            Transport = UseTransport <AzureStorageQueueTransport>();

            var connectionString = Environment.GetEnvironmentVariable(connectionStringName ?? DefaultStorageConnectionString);

            Transport.ConnectionString(connectionString);

            var recoverability = AdvancedConfiguration.Recoverability();

            recoverability.Immediate(settings => settings.NumberOfRetries(4));
            recoverability.Delayed(settings => settings.NumberOfRetries(0));

            Transport.DelayedDelivery().DisableTimeoutManager();

            EndpointConfiguration.UseSerialization <NewtonsoftSerializer>();
        }
示例#10
0
        /// <summary>
        /// Creates a serverless NServiceBus endpoint running with an AmazonSQS SQS trigger.
        /// </summary>
        /// <param name="endpointName">The endpoint name to be used.</param>
        public AwsLambdaSQSEndpointConfiguration(string endpointName)
        {
            EndpointConfiguration = new EndpointConfiguration(endpointName);

            EndpointConfiguration.UsePersistence <InMemoryPersistence>();

            LogManager.Use <LambdaLoggerDefinition>();

            //make sure a call to "onError" will move the message to the error queue.
            EndpointConfiguration.Recoverability().Delayed(c => c.NumberOfRetries(0));
            // send failed messages to the error queue
            recoverabilityPolicy.SendFailedMessagesToErrorQueue = true;
            EndpointConfiguration.Recoverability().CustomPolicy(recoverabilityPolicy.Invoke);

            Transport = UseTransport <SqsTransport>();

            // by default do not write custom diagnostics to file because lambda is readonly
            AdvancedConfiguration.CustomDiagnosticsWriter(diagnostics => Task.CompletedTask);

            TrySpecifyDefaultLicense();
        }
        public ApplicationConfiguration RuntimeSettings <T>(T instance)
            where T : IRuntimeSettings
        {
            Func <IRuntimeSettings> func2 = null;

            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            return(this.Advanced((AdvancedConfiguration advanced) => {
                AdvancedConfiguration advancedConfiguration = advanced;
                Func <IRuntimeSettings> u003cu003e9_1 = func2;
                //if (u003cu003e9_1 == null)
                //{
                //	Func<IRuntimeSettings> func = () => (object)instance;
                //	Func<IRuntimeSettings> func1 = func;
                //	func2 = func;
                //	u003cu003e9_1 = func1;
                //}
                advancedConfiguration.Register <IRuntimeSettings>(u003cu003e9_1);
            }));
        }
示例#12
0
文件: Startup.cs 项目: tuandongoc/CMX
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            //Log Config
            AdvancedConfiguration.ConfigLog4net(Configuration, loggerFactory, "log4net.config", "Logging");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("../swagger/v1/swagger.json", "CMX API V1");
            });

            app.UseAuthentication();
            app.UseMvc();
        }
示例#13
0
 internal void Initialize(SecurityRuntime runtime)
 {
     Runtime        = runtime;
     Advanced       = new AdvancedConfiguration(Runtime);
     PolicyAppender = new DefaultPolicyAppender();
 }
 public void SetConnectionStringTemplateExpressionProp(string value)
 {
     advancedConfiguration = new AdvancedConfiguration(null, null, value);
 }
 public void SetUp()
 {
     _runtime = new SecurityRuntime();
     _advancedConfiguration = new AdvancedConfiguration(_runtime);
 }
示例#16
0
 public void SetUp()
 {
     _advancedConfiguration = new AdvancedConfiguration();
 }
示例#17
0
 public Configuration()
 {
     Advanced = new AdvancedConfiguration();
 }
 public ConfigurationExpression()
 {
     Advanced       = new AdvancedConfiguration();
     PolicyAppender = new DefaultPolicyAppender();
 }
示例#19
0
 public HttpClientConfiguration()
 {
     Advanced = new AdvancedConfiguration();
 }