public void ConfigureUseContainer() { Kick.Start(config => config .IncludeAssemblyFor <TestStartup>() .UseStartupTask(c => c.UseContainer()) ); }
public void Configure() { Kick.Start(config => config .IncludeAssemblyFor <TestStartup>() .UseStartupTask() ); }
public void ConfigureData() { Kick.Start(config => config .LogTo(_output.WriteLine) .Data("name", "value") .Data(d => { d["key"] = 123; d["enviroment"] = "debug"; }) .IncludeAssemblyFor <TestStartup>() .UseStartupTask(c => { c.Run((services, data) => { data.Should().ContainKey("name"); data.Should().ContainKey("key"); data.Should().ContainKey("enviroment"); data["enviroment"].Should().Be("debug"); data["passed"] = "yes"; }); c.Run((services, data) => { data.Should().ContainKey("name"); data.Should().ContainKey("key"); data.Should().ContainKey("enviroment"); data["enviroment"].Should().Be("debug"); data["passed"].Should().Be("yes"); }); }) ); }
public void UseAutofacBuilderLogTo() { string defaultEmail = "*****@*****.**"; Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserModule>() .UseAutofac(c => c .Initialize(b => b .Register(x => new Employee { EmailAddress = defaultEmail } )) ) ); Kick.ServiceProvider.Should().NotBeNull(); Kick.ServiceProvider.Should().BeOfType <AutofacServiceProvider>(); var repo = Kick.ServiceProvider.GetService <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); var employee = Kick.ServiceProvider.GetService <Employee>(); employee.Should().NotBeNull(); employee.EmailAddress.Should().Be(defaultEmail); }
public void UseAutofacBuilderLogTo() { string defaultEmail = "*****@*****.**"; var _logs = new List <LogData>(); Kick.Start(config => config .IncludeAssemblyFor <UserModule>() .UseAutofac(c => c .Builder(b => b .Register(x => new Employee { EmailAddress = defaultEmail } )) ) .LogTo(_logs.Add) ); Kick.Container.Should().NotBeNull(); Kick.Container.Should().BeOfType <AutofacAdaptor>(); Kick.Container.As <IContainer>().Should().BeOfType <Container>(); var repo = Kick.Container.Resolve <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); var employee = Kick.Container.Resolve <Employee>(); employee.Should().NotBeNull(); employee.EmailAddress.Should().Be(defaultEmail); _logs.Should().NotBeEmpty(); }
public void UseServiceInitialize() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserSimpleInjectorRegistration>() .IncludeAssemblyFor <UserServiceModule>() .UseSimpleInjector(s => s.Initialize(c => c.Options.AllowOverridingRegistrations = true)) ); Kick.ServiceProvider.Should().NotBeNull(); Kick.ServiceProvider.Should().BeOfType <Container>(); var userService = Kick.ServiceProvider.GetService <IUserService>(); userService.Should().NotBeNull(); userService.Connection.Should().NotBeNull(); userService.Connection.Should().BeOfType <SampleConnection>(); var vehicleService = Kick.ServiceProvider.GetService <IVehicle>(); vehicleService.Should().NotBeNull(); vehicleService.Should().BeOfType <DeliveryVehicle>(); var minivanService = Kick.ServiceProvider.GetService <IMinivan>(); minivanService.Should().NotBeNull(); minivanService.Should().BeOfType <DeliveryVehicle>(); }
public void Configure() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <TestStartup>() .UseStartupTask() ); }
public void Configure() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <OrderProfile>() .UseEntityChange() ); var original = new Order { Id = Guid.NewGuid().ToString(), OrderNumber = 1000, Total = 10000, }; var current = new Order { Id = Guid.NewGuid().ToString(), OrderNumber = 1000, Total = 11000, Items = new List <OrderLine> { new OrderLine { Sku = "abc-123", Quanity = 1, UnitPrice = 5000 }, } }; var comparer = new EntityComparer(); var changes = comparer.Compare(original, current); changes.Should().NotBeNull(); changes.Count.Should().Be(3); var total = changes.FirstOrDefault(c => c.Path == "Total"); total.Should().NotBeNull(); total.Path.Should().Be("Total"); total.CurrentFormatted.Should().Be("$11,000.00"); var items = changes.FirstOrDefault(c => c.Path == "Items[0]"); items.Should().NotBeNull(); items.Path.Should().Be("Items[0]"); items.CurrentFormatted.Should().Be("abc-123"); items.Operation.Should().Be(ChangeOperation.Add); WriteMarkdown(changes); }
public void UseDependencyInjection() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserDependencyInjectionRegistration>() .UseDependencyInjection() ); Kick.ServiceProvider.Should().NotBeNull(); var repo = Kick.ServiceProvider.GetService <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); }
public void UseNinject() { Kick.Start(config => config .IncludeAssemblyFor <User>() .UseNinject() ); Kick.Container.Should().NotBeNull(); Kick.Container.Should().BeOfType <NinjectAdaptor>(); Kick.Container.As <IKernel>().Should().BeOfType <StandardKernel>(); var repo = Kick.Container.Resolve <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); }
public void UseAutofac() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserModule>() .UseAutofac() ); Kick.ServiceProvider.Should().NotBeNull(); Kick.ServiceProvider.Should().BeOfType <AutofacServiceProvider>(); var repo = Kick.ServiceProvider.GetService <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); }
public void UseUnity() { Kick.Start(config => config .IncludeAssemblyFor <User>() .UseUnity() ); Kick.Container.Should().NotBeNull(); Kick.Container.Should().BeOfType <UnityAdaptor>(); Kick.Container.As <IUnityContainer>().Should().BeOfType <UnityContainer>(); var repo = Kick.Container.Resolve <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); }
public void Configure() { Kick.Start(config => config .IncludeAssemblyFor <UserMap>() .UseMongoDB() ); var isMapped = BsonClassMap.IsClassMapRegistered(typeof(User)); isMapped.Should().BeTrue(); var map = BsonClassMap.LookupClassMap(typeof(User)); map.Should().NotBeNull(); map.IdMemberMap.Should().NotBeNull(); map.IdMemberMap.MemberName.Should().Be("Id"); }
public void UseNinject() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserNinjectModule>() .UseNinject() ); Kick.ServiceProvider.Should().NotBeNull(); Kick.ServiceProvider.Should().BeOfType <StandardKernel>(); Kick.ServiceProvider.As <IKernel>().Should().BeOfType <StandardKernel>(); var repo = Kick.ServiceProvider.GetService <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); }
/// <summary> /// Configure and run the KickStart extensions. /// </summary> /// <param name="services"></param> /// <param name="configurator">The <see langword="delegate"/> to configure KickStart before execution of the extensions.</param> /// <example>Configure KickStart to use startup tasks. /// <code><![CDATA[ /// services.KickStart(config => config /// .IncludeAssemblyFor<Startup>() /// .UseStartupTask() /// );]]></code> /// </example> public static IServiceCollection KickStart(this IServiceCollection services, Action <IConfigurationBuilder> configurator) { var serviceProvider = services.BuildServiceProvider(); var loggerFactory = serviceProvider.GetService <ILoggerFactory>(); var logger = loggerFactory?.CreateLogger(typeof(Kick)); Kick.Start(builder => { builder .LogTo(m => logger?.LogDebug(m)) .UseDependencyInjection(d => d.Creator(() => services)); configurator?.Invoke(builder); }); return(services); }
public void UseServiceInitialize() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserUnityRegistration>() .UseUnity() ); Kick.ServiceProvider.Should().NotBeNull(); Kick.ServiceProvider.Should().BeOfType <UnityServiceProvider>(); var userService = Kick.ServiceProvider.GetService <IUserService>(); userService.Should().NotBeNull(); userService.Connection.Should().NotBeNull(); userService.Connection.Should().BeOfType <SampleConnection>(); }
public void UseServiceInitialize() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserDependencyInjectionRegistration>() .IncludeAssemblyFor <UserServiceModule>() .UseDependencyInjection() ); Kick.ServiceProvider.Should().NotBeNull(); var userRepository = Kick.ServiceProvider.GetService <IUserRepository>(); userRepository.Should().NotBeNull(); userRepository.Should().BeOfType <UserRepository>(); var employeeRepository = Kick.ServiceProvider.GetService <IRepository <Employee> >(); employeeRepository.Should().NotBeNull(); employeeRepository.Should().BeOfType <EmployeeRepository>(); var userService = Kick.ServiceProvider.GetService <IUserService>(); userService.Should().NotBeNull(); userService.Connection.Should().NotBeNull(); userService.Connection.Should().BeOfType <SampleConnection>(); var vehicleService = Kick.ServiceProvider.GetService <IVehicle>(); vehicleService.Should().NotBeNull(); vehicleService.Should().BeOfType <DeliveryVehicle>(); var minivanService = Kick.ServiceProvider.GetService <IMinivan>(); minivanService.Should().NotBeNull(); minivanService.Should().BeOfType <DeliveryVehicle>(); var services = Kick.ServiceProvider.GetServices <IService>().ToList(); services.Should().NotBeNull(); services.Should().NotBeEmpty(); services.Count.Should().Be(3); }
public void MultipleTasks() { //hack use logs to track execution order var logs = new List <string>(); Kick.Start(config => config .LogTo(m => { logs.Add(m); _output.WriteLine(m); }) .IncludeAssemblyFor <TestStartup>() .IncludeAssemblyFor <HighTask>() .UseStartupTask() ); int highExecute = logs.IndexOf("Execute Startup Task; Type: 'KickStart.Tests.StartupTask.HighTask'"); int mediumExecuteA = logs.IndexOf("Execute Startup Task; Type: 'KickStart.Tests.StartupTask.MediumATask'"); int mediumExecuteB = logs.IndexOf("Execute Startup Task; Type: 'KickStart.Tests.StartupTask.MediumBTask'"); int mediumExecuteC = logs.IndexOf("Execute Startup Task; Type: 'KickStart.Tests.StartupTask.MediumCTask'"); int mediumCompleteA = logs.FindIndex(m => m.StartsWith("Complete Startup Task; Type: 'KickStart.Tests.StartupTask.MediumATask'")); int mediumCompleteB = logs.FindIndex(m => m.StartsWith("Complete Startup Task; Type: 'KickStart.Tests.StartupTask.MediumBTask'")); int mediumCompleteC = logs.FindIndex(m => m.StartsWith("Complete Startup Task; Type: 'KickStart.Tests.StartupTask.MediumCTask'")); int startUpExecute = logs.IndexOf("Execute Startup Task; Type: 'Test.Core.Startup.TestStartup'"); // check order by using log position highExecute.Should().BeLessThan(mediumExecuteA); highExecute.Should().BeLessThan(mediumExecuteB); highExecute.Should().BeLessThan(mediumExecuteC); mediumExecuteA.Should().BeLessThan(startUpExecute); mediumExecuteB.Should().BeLessThan(startUpExecute); mediumExecuteC.Should().BeLessThan(startUpExecute); // check parallel, b started before a completed mediumExecuteB.Should().BeLessThan(mediumCompleteA); // check parallel, c started before a completed mediumExecuteC.Should().BeLessThan(mediumCompleteA); // check parallel, c completed before a completed mediumCompleteC.Should().BeLessThan(mediumCompleteA); }
public DependencyInjectionFixture() { Kick.Start(c => c .IncludeAssemblyFor <Project>() .IncludeAssemblyFor <ProjectRepository>() .UseNLog(config => { var consoleTarget = new ConsoleTarget(); consoleTarget.Layout = "${time} ${level:uppercase=true:padding=1:fixedLength=true} ${logger:shortName=true} ${message} ${exception:format=tostring}"; config.AddTarget("console", consoleTarget); var consoleRule = new LoggingRule("*", NLog.LogLevel.Trace, consoleTarget); config.LoggingRules.Add(consoleRule); }) .UseAutofac() .UseMongoDB() .UseStartupTask() ); }
public void UseServiceInitialize() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserModule>() .IncludeAssemblyFor <UserServiceModule>() .UseAutofac() ); Kick.ServiceProvider.Should().NotBeNull(); Kick.ServiceProvider.Should().BeOfType <AutofacServiceProvider>(); var repo = Kick.ServiceProvider.GetService <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); var userService = Kick.ServiceProvider.GetService <IUserService>(); userService.Should().NotBeNull(); userService.Should().BeOfType <UserService>(); userService.Connection.Should().NotBeNull(); userService.Connection.Should().BeOfType <SampleConnection>(); var vehicleService = Kick.ServiceProvider.GetService <IVehicle>(); vehicleService.Should().NotBeNull(); vehicleService.Should().BeOfType <DeliveryVehicle>(); var minivanService = Kick.ServiceProvider.GetService <IMinivan>(); minivanService.Should().NotBeNull(); minivanService.Should().BeOfType <DeliveryVehicle>(); var services = Kick.ServiceProvider.GetServices <IService>().ToList(); services.Should().NotBeNull(); services.Should().NotBeEmpty(); services.Count.Should().Be(3); }
public void UseDependencyInjectionInitialize() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserDependencyInjectionRegistration>() .UseDependencyInjection(c => c .Initialize(b => b.AddTransient <Employee>()) ) ); Kick.ServiceProvider.Should().NotBeNull(); var repo = Kick.ServiceProvider.GetService <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); var employee = Kick.ServiceProvider.GetService <Employee>(); employee.Should().NotBeNull(); }
public void ConfigureBasic() { Kick.Start(config => config .IncludeAssemblyFor <UserProfile>() .UseAutoMapper() ); var employee = new Employee { FirstName = "Test", LastName = "User", EmailAddress = "*****@*****.**", SysVersion = BitConverter.GetBytes(8) }; var user = Mapper.Map <User>(employee); user.Should().NotBeNull(); user.EmailAddress.Should().Be(employee.EmailAddress); user.SysVersion.Should().NotBeNull(); }
public void UseUnityInitialize() { Kick.Start(config => config .IncludeAssemblyFor <User>() .UseUnity(c => c .Container(b => b.RegisterType <Employee>()) ) ); Kick.Container.Should().NotBeNull(); Kick.Container.Should().BeOfType <UnityAdaptor>(); Kick.Container.As <IUnityContainer>().Should().BeOfType <UnityContainer>(); var repo = Kick.Container.Resolve <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); var employee = Kick.Container.Resolve <Employee>(); employee.Should().NotBeNull(); }
public void UseSimpleInjectorInitialize() { Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserSimpleInjectorRegistration>() .UseSimpleInjector(c => c .Container(b => b.Register <Employee>()) ) ); Kick.ServiceProvider.Should().NotBeNull(); Kick.ServiceProvider.Should().BeOfType <Container>(); var repo = Kick.ServiceProvider.GetService <IUserRepository>(); repo.Should().NotBeNull(); repo.Should().BeOfType <UserRepository>(); var employee = Kick.ServiceProvider.GetService <Employee>(); employee.Should().NotBeNull(); }
public void ConfigureFull() { Kick.Start(config => config .IncludeAssemblyFor <UserProfile>() .UseAutoMapper(c => c .Validate() .Initialize(map => map.AddGlobalIgnore("SysVersion")) ) ); var employee = new Employee { FirstName = "Test", LastName = "User", EmailAddress = "*****@*****.**", SysVersion = BitConverter.GetBytes(8) }; var user = Mapper.Map <User>(employee); user.Should().NotBeNull(); user.EmailAddress.Should().Be(employee.EmailAddress); }
public void ConfigureFull() { Mapper.Reset(); Kick.Start(config => config .LogTo(_output.WriteLine) .IncludeAssemblyFor <UserProfile>() .UseAutoMapper(c => c .Validate() ) ); var employee = new Employee { FirstName = "Test", LastName = "User", EmailAddress = "*****@*****.**", SysVersion = BitConverter.GetBytes(8) }; var user = Mapper.Map <User>(employee); user.Should().NotBeNull(); user.EmailAddress.Should().Be(employee.EmailAddress); }
public void Configuration(IAppBuilder app) { var config = GlobalConfiguration.Configuration; Kick.Start(c => c .IncludeAssemblyFor <Startup>() .IncludeAssemblyFor <Project>() .IncludeAssemblyFor <ProjectRepository>() .UseNLog() .UseAutofac(a => a .Initialize(b => { b.RegisterControllers(typeof(Startup).Assembly); b.RegisterApiControllers(typeof(Startup).Assembly); }) .Container(r => { DependencyResolver.SetResolver(new AutofacDependencyResolver(r)); config.DependencyResolver = new AutofacWebApiDependencyResolver(r); }) ) .UseMongoDB() .UseStartupTask() ); // security app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), LogoutPath = new PathString("/Account/Logout"), CookieName = ".Estimatorx.Authentication", Provider = new CookieAuthenticationProvider() }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // social logins if (!string.IsNullOrEmpty(EstimatorxSettings.MicrosoftClientId)) { app.UseMicrosoftAccountAuthentication( clientId: EstimatorxSettings.MicrosoftClientId, clientSecret: EstimatorxSettings.MicrosoftClientSecret); } if (!string.IsNullOrEmpty(EstimatorxSettings.TwitterConsumerKey)) { app.UseTwitterAuthentication( consumerKey: EstimatorxSettings.TwitterConsumerKey, consumerSecret: EstimatorxSettings.TwitterConsumerSecret); } if (!string.IsNullOrEmpty(EstimatorxSettings.FacebookApplicationId)) { app.UseFacebookAuthentication( appId: EstimatorxSettings.FacebookApplicationId, appSecret: EstimatorxSettings.FacebookApplicationSecret); } if (!string.IsNullOrEmpty(EstimatorxSettings.GoogleClientId)) { app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions { ClientId = EstimatorxSettings.GoogleClientId, ClientSecret = EstimatorxSettings.GoogleClientSecret }); } if (!string.IsNullOrEmpty(EstimatorxSettings.GitHubClientId)) { app.UseGitHubAuthentication(new GitHubAuthenticationOptions { ClientId = EstimatorxSettings.GitHubClientId, ClientSecret = EstimatorxSettings.GitHubClientSecret, Scope = { "user:email" } }); } }