public void SetUp() { testConnection = new TestConnection(); serviceLocator = new ThreadedServiceLocator(new SiegeAdapter()) .Register(Given <Func <DbContext> > .Then(() => new DbContext(testConnection, true))) // .Register(Given<DbContext>.ConstructWith(new List<IResolutionArgument>() { new ConstructorParameter() { Name = "nameOrConnectionString", Value = "MyConnectionString" } })) .Register(Using.Convention(new EntityFrameworkConvention <ThreadedUnitOfWorkStore, NullDatabase, DbContext>())); }
public void SetUp() { serviceLocator = new ThreadedServiceLocator(new SiegeAdapter()); mocks = new MockRepository(); sessionFactory = mocks.DynamicMock <ISessionFactory>(); serviceLocator.Register( Using.Convention(new NHibernateConvention <ThreadedUnitOfWorkStore, NullDatabase>(sessionFactory))); }
protected override void OnApplicationStarted() { base.OnApplicationStarted(); ServiceLocator .Register(Using.Convention <TemplateConvention>()) .Register(Using.Convention <ControllerConvention <HomeController> >()) .Register(Given <WCFAdapter> .Then <WCFAdapter>()) .Register(Given <IConfigurationManager> .Then <ServiceBusConfigurationManager>()) .Register(Given <IChannelManagerFactory> .Then <WCFChannelManagerFactory>()) .Register(Given <IChannelManager <IWCFProtocol> > .ConstructWith(x => { var config = x.GetInstance <IConfigurationManager>(); return(x.GetInstance <WCFChannelManagerFactory>().Create <IWCFProtocol>(config.ServiceBusEndPoint)); })) .Register(Given <WCFProxy <IWCFProtocol> > .Then <WCFProxy <IWCFProtocol> >()) .Register(Given <AccountSubscriber> .Then <AccountSubscriber>()) .Register(Given <IMessageBucket> .Then <HttpMessageBucket>()) .Register(Given <IFormsAuthenticationService> .Then <FormsAuthenticationService>()); MapMessage <LogOnAccountMessage, WCFAdapter>(); AddSubscriber <AccountSubscriber, MemberAuthenticatedMessage>(); AddSubscriber <AccountSubscriber, MemberFailedAuthenticationMessage>(); AddSubscriber <AccountSubscriber, MessageValidationFailedMessage <LogOnAccountMessage> >(); var engine = new TemplateViewEngine(() => ServiceLocator.Store.Get <IContextStore>().Items); engine.UseConvention(new SampleConvention()); //engine // .For<HomeController>(controller => controller.Index()) // .Map( // To.Path("LOL").When<bool>(x => x) // ); //engine // .ForPartial("LogOnUserControl") // .Map( // To.Path("~/Views/Shared/LogOnUserControl.ascx"), // To.Path("~/Views/LOL/LOLUserControl.ascx").When<bool>(x => x) // ); //engine // .Map( // To.Path("~/Views/Home/"), // To.Path("~/Views/LOL/").When<bool>(x => x), // To.Master("~/Views/Shared/Site.master"), // To.Master("~/Views/LOL/LOL.master").When<bool>(x => x) // ); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(engine); ServiceLocator.AddContext(true); }
protected override void OnApplicationStarted() { RegisterGlobalFilters(GlobalFilters.Filters); BundleTable.Bundles.RegisterTemplateBundles(); base.OnApplicationStarted(); ServiceLocator .Register(Given <IAuthenticationProvider> .Then <WebAuthenticationProvider>()) .Register(Using.Convention(new SqlSecurityAdminConvention())) .Register(Using.Convention <ControllerConvention <AccountController> >()); }
public virtual void ShouldProxyAllTypes() { locator.Register(Using.Convention <SampleProxyAttributeConvention>()); locator.Register(Using.Convention <ProxyConvention>()); locator.Register(Given <TestType2> .Then <TestType2>()); var testType2 = locator.GetInstance <TestType2>(); Assert.AreEqual("lolarg1", testType2.Test("arg1", "arg2")); Assert.AreEqual(3, Counter.Count); Counter.Count = 0; }
protected override void OnApplicationStarted() { ServiceLocator .Register(Using.Convention <AspNetMvcConvention>()) .Register(Using.Convention <ServiceBusConvention>()) .Register(Given <MessageMap> .Then(Map)); AddResponse <ViewResponse>("view"); AddResponse <JsonResponse>("json"); RouteTable.Routes.Add(ServiceLocator.GetInstance <ServiceBusRoute>()); base.OnApplicationStarted(); }
public Action <IServiceLocator> Build() { return(locator => { locator .Register(Using.Convention <ControllerConvention <HomeController> >()) .Register(Using.Convention <EntityFrameworkConvention <HttpUnitOfWorkStore, SecurityDatabase, SecurityContext> >()) .Register(Using.Convention <SqlSecurityConvention>()); RegisterModelBinder <JqGridConfiguration, JqGridConfigurationModelBinder>(locator); RegisterModelBinder <List <Role>, RolesBinder>(locator); RegisterModelBinder <List <Group>, GroupsBinder>(locator); RegisterModelBinder <List <Application>, ApplicationsBinder>(locator); RegisterModelBinder <List <Permission>, PermissionsBinder>(locator); RegisterModelBinder <User, UserBinder>(locator); RegisterModelBinder <Application, ApplicationBinder>(locator); RegisterModelBinder <Group, GroupBinder>(locator); RegisterModelBinder <Consumer, ConsumerBinder>(locator); RegisterModelBinder <Role, RoleBinder>(locator); }); }
public void ShouldUseGeneric() { locator.Register(Using.Convention <NamespaceTestConvention>()); Assert.IsInstanceOf <GenericTest>(locator.GetInstance <ITest <AutoScannedType> >()); }
public void ShouldUseNamespace() { locator.Register(Using.Convention <NamespaceTestConvention>()); Assert.IsInstanceOf <AutoScanningConventionTest>(locator.GetInstance <ITest>()); Assert.IsFalse(locator.HasTypeRegistered(typeof(IAutoScannedInterface))); }
public void ShouldUseSimpleAutoScanningConventions() { locator.Register(Using.Convention <TestConvention>()); Assert.IsInstanceOf <AutoScannedType>(locator.GetInstance <IAutoScannedInterface>()); }