コード例 #1
0
 public static BootstrapperOptions BoltOnMartenDbModule(this BootstrapperOptions bootstrapperOptions,
                                                        StoreOptions storeOptions)
 {
     bootstrapperOptions.BoltOnAssemblies(Assembly.GetExecutingAssembly());
     bootstrapperOptions.ServiceCollection.AddMarten(storeOptions);
     return(bootstrapperOptions);
 }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: gokulm/BoltOn
 public static BootstrapperOptions BoltOnCacheModule(this BootstrapperOptions bootstrapperOptions)
 {
     bootstrapperOptions.BoltOnAssemblies(Assembly.GetExecutingAssembly());
     bootstrapperOptions.ServiceCollection.AddTransient <IAppCache, AppCache>();
     bootstrapperOptions.AddInterceptor <CacheResponseInterceptor>().After <StopwatchInterceptor>();
     return(bootstrapperOptions);
 }
コード例 #3
0
        public void Dependencies_FindDependenciesFile()
        {
            //arrange
            var fs  = new Mock <IFileSystemProxy>();
            var cwd = Directory.GetCurrentDirectory();

            var subDir          = Path.Combine(cwd, "testing", "subdir");
            var depsFile        = Path.Combine(cwd, PaketDependencies.DEPENDENCY_FILE);
            var depsFileContent = "version 5.0.0-beta008";
            var depsFileStream  = new MemoryStream(Encoding.UTF8.GetBytes(depsFileContent));

            fs.Setup(f => f.GetCurrentDirectory()).Returns(subDir);
            fs.Setup(f => f.FileExists(It.IsAny <string>())).Returns(false);
            fs.Setup(f => f.FileExists(depsFile)).Returns(true);
            fs.Setup(f => f.OpenRead(depsFile)).Returns(depsFileStream);

            //act
            var opts      = new BootstrapperOptions();
            var argstring = PaketDependencies.GetBootstrapperArgsForFolder(fs.Object);
            var args      = WindowsProcessArguments.Parse(argstring);

            ArgumentParser.FillNonRunOptionsFromArguments(opts, args);

            //assert
            Assert.That(opts.DownloadArguments.LatestVersion, Is.EqualTo("5.0.0-beta008"));
        }
コード例 #4
0
ファイル: Extensions.cs プロジェクト: gokulm/BoltOn
 public static BootstrapperOptions BoltOnMassTransitBusModule(this BootstrapperOptions bootstrapperOptions)
 {
     bootstrapperOptions.BoltOnAssemblies(Assembly.GetExecutingAssembly());
     bootstrapperOptions.ServiceCollection.AddSingleton <IAppServiceBus, AppServiceBus>();
     bootstrapperOptions.ServiceCollection.AddTransient(typeof(AppMessageConsumer <>));
     return(bootstrapperOptions);
 }
コード例 #5
0
        public JsonResult BootstrapBuilder()
        {
            var model = new BootstrapperOptions()
            {
                AvailableVersions = _availableOptions
            };

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #6
0
        public JsonResult BootstrapBuilder()
        {
            var model = new BootstrapperOptions()
            {
                AvailableVersions = _availableOptions
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public static IServiceCollection BoltOn(this IServiceCollection serviceCollection, Action <BootstrapperOptions> action = null)
        {
            var options = new BootstrapperOptions(serviceCollection);

            action?.Invoke(options);
            options.RegisterByConvention(Assembly.GetCallingAssembly());
            options.RegisterInterceptors();
            serviceCollection.AddSingleton(options);
            return(serviceCollection);
        }
コード例 #8
0
ファイル: Extensions.cs プロジェクト: gokulm/BoltOn
        public static BootstrapperOptions BoltOnAuthorizationModule(this BootstrapperOptions bootstrapperOptions)
        {
            _isAuthorizationModuleAdded = true;
            var serviceCollection = bootstrapperOptions.ServiceCollection;

            serviceCollection.AddTransient <IClaimsService, DefaultClaimsService>();
            serviceCollection.AddScoped <IAuthorizationHandler, ScopeAuthorizationHandler>();
            serviceCollection.AddScoped <IAuthorizationHandler, PermissionAuthorizationHandler>();
            serviceCollection.AddSingleton <IAuthorizationPolicyProvider, AppPolicyProvider>();
            return(bootstrapperOptions);
        }
コード例 #9
0
        public static void SetupFakes(this BootstrapperOptions bootstrapperOptions)
        {
            if (IntegrationTestHelper.IsElasticsearchServer)
            {
                var uri = new Uri("http://localhost:9200/");
                bootstrapperOptions.ServiceCollection.AddElasticsearch <TestElasticsearchOptions>(e =>
                {
                    e.ConnectionSettings = new Nest.ConnectionSettings(uri);
                });

                bootstrapperOptions.ServiceCollection.AddTransient <IRepository <Student>, Repository <Student, TestElasticsearchOptions> >();
            }
        }
コード例 #10
0
        public static IHostBuilder UseBootstrapperFactory(this IHostBuilder builder, IAssemblyCatalog assemblyCatalog,
                                                          BootstrapperOptions options, IEnumerable <ModuleMetadataValidator> validators = null)
        {
            return(builder.UseServiceProviderFactory(context =>
            {
                var moduleLoader = new ModuleLoader(validators);

                options.ConfigureBuildTimeServices.Add(collection => collection.AddSingleton(context.HostingEnvironment));
                options.ConfigureBuildTimeServices.Add(collection => collection.AddSingleton(context.Configuration));

                return BootstrapperFactory.Create(moduleLoader, assemblyCatalog, options);
            }));
        }
コード例 #11
0
ファイル: Bootstrapper.cs プロジェクト: EtwasGE/EntityHistory
        private Bootstrapper([NotNull] Type startupModule, [CanBeNull] Action <BootstrapperOptions> optionsAction = null)
        {
            Check.NotNull(startupModule, nameof(startupModule));

            var options = new BootstrapperOptions();

            optionsAction?.Invoke(options);

            if (!typeof(IModule).GetTypeInfo().IsAssignableFrom(startupModule))
            {
                throw new ArgumentException($"{nameof(startupModule)} should be derived from {nameof(IModule)}.");
            }

            _startupModuleType = startupModule;
        }
コード例 #12
0
        public static void RegisterCqrsFakes(this BootstrapperOptions bootstrapperOptions)
        {
            bootstrapperOptions.ServiceCollection.AddLogging();
            bootstrapperOptions.ServiceCollection.AddDbContext <SchoolDbContext>(options =>
            {
                options.UseInMemoryDatabase(Guid.NewGuid().ToString());
                options.ConfigureWarnings(x => x.Ignore(RelationalEventId.AmbientTransactionWarning));
            });

            bootstrapperOptions.ServiceCollection.AddTransient <IRepository <Student>,
                                                                CqrsRepository <Student, SchoolDbContext> >();
            bootstrapperOptions.ServiceCollection.AddTransient <IRepository <StudentFlattened>,
                                                                Repository <StudentFlattened, SchoolDbContext> >();
            bootstrapperOptions.ServiceCollection.AddTransient <IRepository <EventStore>,
                                                                Repository <EventStore, SchoolDbContext> >();
        }
コード例 #13
0
        public void AddInterceptor_AfterAnInterceptorThatDoesntExist_ReturnsInterceptorsInExpectedOrder()
        {
            // arrange
            var serviceCollection   = new Moq.Mock <IServiceCollection>();
            var bootstrapperOptions = new BootstrapperOptions(serviceCollection.Object);

            // act
            bootstrapperOptions.AddInterceptor <StopwatchInterceptor>();

            // assert
            var interceptorTypes                  = bootstrapperOptions.InterceptorTypes.ToList();
            var stopWatchInterceptorIndex         = interceptorTypes.IndexOf(typeof(StopwatchInterceptor));
            var testBootstrappingInterceptorIndex = interceptorTypes.IndexOf(typeof(TestBootstrappingInterceptor));

            Assert.True(stopWatchInterceptorIndex != -1);
            Assert.True(testBootstrappingInterceptorIndex == -1);
        }
コード例 #14
0
        public void AddInterceptor_BeforeAnAlreadyAddedInterceptor_ReturnsInterceptorsInExpectedOrder()
        {
            // arrange
            var serviceCollection   = new Moq.Mock <IServiceCollection>();
            var bootstrapperOptions = new BootstrapperOptions(serviceCollection.Object);

            // act
            bootstrapperOptions.AddInterceptor <TransactionInterceptor>().Before <StopwatchInterceptor>();

            // assert
            var interceptorTypes            = bootstrapperOptions.InterceptorTypes.ToList();
            var stopWatchInterceptorIndex   = interceptorTypes.IndexOf(typeof(StopwatchInterceptor));
            var transactionInterceptorIndex = interceptorTypes.IndexOf(typeof(TransactionInterceptor));

            Assert.True(stopWatchInterceptorIndex != -1);
            Assert.True(transactionInterceptorIndex != -1);
            Assert.True(transactionInterceptorIndex < stopWatchInterceptorIndex);
        }
コード例 #15
0
        public static void RegisterDataFakes(this BootstrapperOptions bootstrapperOptions)
        {
            bootstrapperOptions.ServiceCollection.AddTransient <IRepository <Student>, Repository <Student, SchoolDbContext> >();
            bootstrapperOptions.ServiceCollection.AddTransient <IQueryRepository <Student>, QueryRepository <Student, SchoolDbContext> >();

            if (IntegrationTestHelper.IsSqlServer)
            {
                bootstrapperOptions.ServiceCollection.AddDbContext <SchoolDbContext>(options =>
                {
                    options.UseSqlServer("Data Source=127.0.0.1;initial catalog=Testing;persist security info=True;User ID=sa;Password=Password1;");
                });
            }
            else
            {
                bootstrapperOptions.ServiceCollection.AddDbContext <SchoolDbContext>(options =>
                {
                    options.UseInMemoryDatabase("InMemoryDbForTesting");
                });
            }
        }
コード例 #16
0
        public static void RegisterRequestorFakes(this BootstrapperOptions bootstrapperOptions)
        {
            bootstrapperOptions.ServiceCollection.AddLogging();
            var appClock        = new Mock <IAppClock>();
            var currentDateTime = DateTime.Parse("10/27/2018 12:51:59 PM");

            appClock.Setup(s => s.Now).Returns(currentDateTime);
            bootstrapperOptions.ServiceCollection.AddTransient((s) => appClock.Object);

            var testInterceptorLogger = new Mock <IAppLogger <TestInterceptor> >();

            testInterceptorLogger.Setup(s => s.Debug(It.IsAny <string>()))
            .Callback <string>(st => RequestorTestHelper.LoggerStatements.Add(st));
            bootstrapperOptions.ServiceCollection.AddTransient((s) => testInterceptorLogger.Object);

            var stopWatchInterceptorLogger = new Mock <IAppLogger <StopwatchInterceptor> >();

            stopWatchInterceptorLogger.Setup(s => s.Debug(It.IsAny <string>()))
            .Callback <string>(st => RequestorTestHelper.LoggerStatements.Add(st));
            bootstrapperOptions.ServiceCollection.AddTransient((s) => stopWatchInterceptorLogger.Object);

            var transactionInterceptorLogger = new Mock <IAppLogger <TransactionInterceptor> >();

            transactionInterceptorLogger.Setup(s => s.Debug(It.IsAny <string>()))
            .Callback <string>(st => RequestorTestHelper.LoggerStatements.Add(st));
            bootstrapperOptions.ServiceCollection.AddTransient((s) => transactionInterceptorLogger.Object);

            if (RequestorTestHelper.IsClearInterceptors)
            {
                bootstrapperOptions.RemoveAllInterceptors();
            }

            if (RequestorTestHelper.IsRemoveStopwatchInterceptor)
            {
                bootstrapperOptions.RemoveInterceptor <StopwatchInterceptor>();
            }

            bootstrapperOptions.AddInterceptor <TestInterceptor>();
        }
コード例 #17
0
ファイル: Extensions.cs プロジェクト: gokulm/BoltOn
 public static BootstrapperOptions BoltOnElasticsearchModule(this BootstrapperOptions bootstrapperOptions)
 {
     bootstrapperOptions.BoltOnAssemblies(Assembly.GetExecutingAssembly());
     return(bootstrapperOptions);
 }
コード例 #18
0
 public static BootstrapperOptions BoltOnHangfireModule(this BootstrapperOptions bootstrapperOptions)
 {
     bootstrapperOptions.BoltOnAssemblies(Assembly.GetExecutingAssembly());
     bootstrapperOptions.ServiceCollection.AddTransient <AppHangfireJobProcessor>();
     return(bootstrapperOptions);
 }
コード例 #19
0
 public InterceptorOptions(BootstrapperOptions bootstrapperOptions)
 {
     BootstrapperOptions = bootstrapperOptions;
 }
コード例 #20
0
ファイル: Extensions.cs プロジェクト: gokulm/BoltOn
 public static BootstrapperOptions BoltOnWebModule(this BootstrapperOptions bootstrapperOptions)
 {
     _isWebModuleAdded = true;
     bootstrapperOptions.BoltOnAssemblies(Assembly.GetExecutingAssembly());
     return(bootstrapperOptions);
 }