public void Init()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <MembershipService>().As <IMembershipService>();
            builder.RegisterType <UserService>().As <IUserService>();
            builder.RegisterInstance(_clock = new StubClock()).As <IClock>();
            builder.RegisterType <DefaultContentQuery>().As <IContentQuery>();
            builder.RegisterType <DefaultContentManager>().As <IContentManager>();
            builder.RegisterType(typeof(SettingsFormatter)).As <ISettingsFormatter>();
            builder.RegisterType <ContentDefinitionManager>().As <IContentDefinitionManager>();
            builder.RegisterType <DefaultContentManagerSession>().As <IContentManagerSession>();
            builder.RegisterType <UserPartHandler>().As <IContentHandler>();
            builder.RegisterType <StubWorkContextAccessor>().As <IWorkContextAccessor>();
            builder.RegisterType <OrchardServices>().As <IOrchardServices>();
            builder.RegisterAutoMocking(MockBehavior.Loose);
            builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>));
            builder.RegisterInstance(new Mock <IMessageEventHandler>().Object);
            builder.RegisterType <DefaultMessageManager>().As <IMessageManager>();
            builder.RegisterInstance(_channel = new MessagingChannelStub()).As <IMessagingChannel>();
            builder.RegisterType <DefaultShapeTableManager>().As <IShapeTableManager>();
            builder.RegisterType <DefaultShapeFactory>().As <IShapeFactory>();
            builder.RegisterType <StubExtensionManager>().As <IExtensionManager>();
            builder.RegisterType <DefaultContentDisplay>().As <IContentDisplay>();

            builder.RegisterType <DefaultEncryptionService>().As <IEncryptionService>();
            builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(new TestSessionLocator(_session)).As <ISessionLocator>();
            _container         = builder.Build();
            _membershipService = _container.Resolve <IMembershipService>();
            _userService       = _container.Resolve <IUserService>();
        }
예제 #2
0
        public override void Register(ContainerBuilder builder)
        {
            builder.RegisterType <CommentService>().As <ICommentService>();
            builder.RegisterType <DefaultContentManager>().As <IContentManager>();
            builder.RegisterType <StubCacheManager>().As <ICacheManager>();
            builder.RegisterType <Signals>().As <ISignals>();
            builder.RegisterType <DefaultContentManagerSession>().As <IContentManagerSession>();
            builder.RegisterInstance(new Mock <IContentDefinitionManager>().Object);
            builder.RegisterInstance(new Mock <IAuthorizer>().Object);
            builder.RegisterInstance(new Mock <INotifier>().Object);
            builder.RegisterInstance(new Mock <IContentDisplay>().Object);
            builder.RegisterInstance(new Mock <IAuthenticationService>().Object);
            builder.RegisterType <OrchardServices>().As <IOrchardServices>();
            builder.RegisterType <DefaultShapeTableManager>().As <IShapeTableManager>();
            builder.RegisterType <DefaultShapeFactory>().As <IShapeFactory>();
            builder.RegisterType <StubWorkContextAccessor>().As <IWorkContextAccessor>();
            builder.RegisterType <CommentedItemHandler>().As <IContentHandler>();
            builder.RegisterType <DefaultContentQuery>().As <IContentQuery>();
            builder.RegisterType <CommentPartHandler>().As <IContentHandler>();
            builder.RegisterType <CommonPartHandler>().As <IContentHandler>();
            builder.RegisterType <StubExtensionManager>().As <IExtensionManager>();
            builder.RegisterType <DefaultEncryptionService>().As <IEncryptionService>();
            builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());
            builder.RegisterType <ProcessingEngineStub>().As <IProcessingEngine>();
            builder.RegisterType <StubShellDescriptorManager>().As <IShellDescriptorManager>();
            builder.RegisterType <DefaultShapeFactory>().As <IShapeFactory>();

            builder.RegisterInstance(new Mock <IShapeTableLocator>().Object);
            builder.RegisterInstance(new Mock <IShapeDisplay>().Object);
            builder.RegisterInstance(new Mock <IMessageService>().Object);
            builder.RegisterType <StubClock>().As <IClock>();
            builder.RegisterInstance(new Mock <IPageClassBuilder>().Object);
            builder.RegisterType <DefaultContentDisplay>().As <IContentDisplay>();
            builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>));
        }
        public override void Register(ContainerBuilder builder)
        {
            _channel = new MessagingChannelStub();

            builder.RegisterType <AccountController>().SingleInstance();
            builder.RegisterType <SiteService>().As <ISiteService>();
            builder.RegisterType <DefaultContentManager>().As <IContentManager>();
            builder.RegisterType(typeof(SettingsFormatter)).As <ISettingsFormatter>();
            builder.RegisterType <ContentDefinitionManager>().As <IContentDefinitionManager>();
            builder.RegisterType <DefaultContentManagerSession>().As <IContentManagerSession>();
            builder.RegisterType <DefaultContentQuery>().As <IContentQuery>().InstancePerDependency();

            builder.RegisterInstance(new Mock <IAuthenticationService>().Object);
            builder.RegisterInstance(new Mock <IUserEventHandler>().Object);
            builder.RegisterInstance(new Mock <IAppConfigurationAccessor>().Object);
            builder.RegisterType <MembershipService>().As <IMembershipService>();
            builder.RegisterType <DefaultMessageService>().As <IMessageService>();
            builder.RegisterInstance(new MessageChannelSelectorStub(_channel)).As <IMessageChannelSelector>();
            builder.RegisterType <MessageChannelManager>().As <IMessageChannelManager>();
            builder.RegisterType <ShapeDisplayStub>().As <IShapeDisplay>();
            builder.RegisterType <UserService>().As <IUserService>();
            builder.RegisterType <UserPartHandler>().As <IContentHandler>();
            builder.RegisterType <OrchardServices>().As <IOrchardServices>();

            builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As <ITransactionManager>();
            builder.RegisterInstance(new Work <IEnumerable <IShapeTableEventHandler> >(resolve => _container.Resolve <IEnumerable <IShapeTableEventHandler> >())).AsSelf();
            builder.RegisterType <DefaultShapeTableManager>().As <IShapeTableManager>();
            builder.RegisterType <DefaultShapeFactory>().As <IShapeFactory>();
            builder.RegisterType <StubExtensionManager>().As <IExtensionManager>();
            builder.RegisterType <SiteSettingsPartHandler>().As <IContentHandler>();
            builder.RegisterType <RegistrationSettingsPartHandler>().As <IContentHandler>();
            builder.RegisterType <ShapeTableLocator>().As <IShapeTableLocator>();

            builder.RegisterInstance(new Mock <INotifier>().Object);
            builder.RegisterInstance(new Mock <IContentDisplay>().Object);
            builder.RegisterType <StubCacheManager>().As <ICacheManager>();
            builder.RegisterType <StubParallelCacheContext>().As <IParallelCacheContext>();
            builder.RegisterType <Signals>().As <ISignals>();

            builder.RegisterType <DefaultEncryptionService>().As <IEncryptionService>();
            builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());

            _authorizer = new Mock <IAuthorizer>();
            builder.RegisterInstance(_authorizer.Object);

            _authorizer.Setup(x => x.Authorize(It.IsAny <Permission>(), It.IsAny <LocalizedString>())).Returns(true);

            _workContext = new Mock <WorkContext>();
            _workContext.Setup(w => w.GetState <ISite>(It.Is <string>(s => s == "CurrentSite"))).Returns(() => { return(_container.Resolve <ISiteService>().GetSiteSettings()); });

            var _workContextAccessor = new Mock <IWorkContextAccessor>();

            _workContextAccessor.Setup(w => w.GetContext()).Returns(_workContext.Object);
            builder.RegisterInstance(_workContextAccessor.Object).As <IWorkContextAccessor>();
        }
예제 #4
0
        public void Init()
        {
            var builder = new ContainerBuilder();

            _channel = new MessagingChannelStub();

            builder.RegisterType <MembershipService>().As <IMembershipService>();
            builder.RegisterType <UserService>().As <IUserService>();
            builder.RegisterInstance(_clock = new StubClock()).As <IClock>();
            builder.RegisterType <DefaultContentQuery>().As <IContentQuery>();
            builder.RegisterType <DefaultContentManager>().As <IContentManager>();
            builder.RegisterType <StubCacheManager>().As <ICacheManager>();
            builder.RegisterType <Signals>().As <ISignals>();
            builder.RegisterType(typeof(SettingsFormatter)).As <ISettingsFormatter>();
            builder.RegisterType <ContentDefinitionManager>().As <IContentDefinitionManager>();
            builder.RegisterType <DefaultContentManagerSession>().As <IContentManagerSession>();
            builder.RegisterType <UserPartHandler>().As <IContentHandler>();
            builder.RegisterType <StubWorkContextAccessor>().As <IWorkContextAccessor>();
            builder.RegisterType <OrchardServices>().As <IOrchardServices>();
            builder.RegisterAutoMocking(MockBehavior.Loose);
            builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>));
            builder.RegisterInstance(new MessageChannelSelectorStub(_channel)).As <IMessageChannelSelector>();
            builder.RegisterType <DefaultShapeTableManager>().As <IShapeTableManager>();
            builder.RegisterType <DefaultShapeFactory>().As <IShapeFactory>();
            builder.RegisterType <StubExtensionManager>().As <IExtensionManager>();
            builder.RegisterInstance(new Mock <IPageClassBuilder>().Object);
            builder.RegisterType <DefaultContentDisplay>().As <IContentDisplay>();
            builder.RegisterType <InfosetHandler>().As <IContentHandler>();
            builder.RegisterType <SiteService>().As <ISiteService>();
            builder.RegisterType <SiteSettingsPartHandler>().As <IContentHandler>();
            builder.RegisterType <RegistrationSettingsPartHandler>().As <IContentHandler>();

            _workContext = new Mock <WorkContext>();
            _workContext.Setup(w => w.GetState <ISite>(It.Is <string>(s => s == "CurrentSite"))).Returns(() => { return(_container.Resolve <ISiteService>().GetSiteSettings()); });

            var _workContextAccessor = new Mock <IWorkContextAccessor>();

            _workContextAccessor.Setup(w => w.GetContext()).Returns(_workContext.Object);
            builder.RegisterInstance(_workContextAccessor.Object).As <IWorkContextAccessor>();

            builder.RegisterType <DefaultEncryptionService>().As <IEncryptionService>();
            builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(new TestTransactionManager(_session)).As <ITransactionManager>();

            _container         = builder.Build();
            _membershipService = _container.Resolve <IMembershipService>();
            _userService       = _container.Resolve <IUserService>();
        }
예제 #5
0
        public override void Register(ContainerBuilder builder)
        {
            builder.RegisterType <DefaultSslSettingsProvider>().As <ISslSettingsProvider>();
            builder.RegisterType <VerifyCodeGenerator>().As <IVerifyCodeGenerator>();
            builder.RegisterType <QCloudSMSHelper>().As <ISMSHelper>();
            builder.RegisterType <DefaultEncryptionService>().As <IEncryptionService>();
            builder.RegisterType <MerchantService>().As <IMerchantService>();
            builder.RegisterType <EnjoyAuthService>().As <IEnjoyAuthService>();
            builder.RegisterType <QCloudSMSHelper>().As <ISMSHelper>();
            builder.RegisterType <VerifyCodeGenerator>().As <IVerifyCodeGenerator>();
            builder.RegisterType <WeChatApi>().As <IWeChatApi>();
            builder.RegisterType <OrchardServices>().As <IOrchardServices>();
            builder.RegisterType <DefaultContentManager>().As <IContentManager>();
            builder.RegisterType <StubCacheManager>().As <ICacheManager>();
            builder.RegisterType <Signals>().As <ISignals>();
            builder.RegisterType <DefaultContentManagerSession>().As <IContentManagerSession>();
            builder.RegisterInstance(new Mock <IContentDefinitionManager>().Object);
            builder.RegisterInstance(new Mock <IAuthorizer>().Object);
            builder.RegisterInstance(new Mock <INotifier>().Object);
            builder.RegisterInstance(new Mock <IContentDisplay>().Object);
            builder.RegisterInstance(new Mock <IAuthenticationService>().Object);
            builder.RegisterType <OrchardServices>().As <IOrchardServices>();
            builder.RegisterType <DefaultShapeTableManager>().As <IShapeTableManager>();
            builder.RegisterType <DefaultShapeFactory>().As <IShapeFactory>();
            builder.RegisterType <StubWorkContextAccessor>().As <IWorkContextAccessor>();
            builder.RegisterType <DefaultContentQuery>().As <IContentQuery>();

            builder.RegisterType <StubExtensionManager>().As <IExtensionManager>();
            builder.RegisterType <DefaultEncryptionService>().As <IEncryptionService>();
            builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());
            builder.RegisterType <ProcessingEngineStub>().As <IProcessingEngine>();
            builder.RegisterType <StubShellDescriptorManager>().As <IShellDescriptorManager>();
            builder.RegisterType <DefaultShapeFactory>().As <IShapeFactory>();

            builder.RegisterInstance(new Mock <IShapeTableLocator>().Object);
            builder.RegisterInstance(new Mock <IShapeDisplay>().Object);
            builder.RegisterInstance(new Mock <IMessageService>().Object);
            builder.RegisterType <StubClock>().As <IClock>();
            builder.RegisterInstance(new Mock <IPageClassBuilder>().Object);
            builder.RegisterType <DefaultContentDisplay>().As <IContentDisplay>();
            builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>));

            builder.RegisterType <MembershipService>().As <IMembershipService>();

            var _stubContextAccessor = new StubHttpContextAccessor();

            builder.RegisterInstance(_stubContextAccessor).As <IHttpContextAccessor>();
            builder.RegisterInstance(new Mock <IUserEventHandler>().Object);
            builder.RegisterInstance(new Mock <IAppConfigurationAccessor>().Object);
            builder.RegisterType <WeChatMsgHandler>().As <IWeChatMsgHandler>();
            builder.RegisterType <CardCouponService>().As <ICardCouponService>();
            builder.RegisterType <WxUserService>().As <IWxUserService>();

            builder.RegisterTypes(new System.Type[] {
                typeof(AuditNotPassWeChatMsgBehavior),
                typeof(AuditPassWeChatMsgBehavior),
                typeof(CardPayOrderWeChatMsgBehavior),
                typeof(CardSkuRemindWeChatMsgBehavior),
                typeof(DoNothingWeChatMsgBehavior),
                typeof(MerchantAuditWeChatMsgBehavior),
                typeof(SubmitMemberCardWeChatMsgBehavior),
                typeof(UpdateMemberCardWeChatMsgBehavior),
                typeof(UserConsumeCardWechatMsgBehavior),
                typeof(UserDelCardWeChatMsgBehavior),
                typeof(UserEnterSessionFromCardWeChatMsgBehavior),
                typeof(UserGetCardWeChatMsgBehavior),
                typeof(UserGiftingCardWeChatMsgBehavior),
                typeof(UserPayFromPayCellWeChatMsgBehavior),
                typeof(UserViewCardWeChatMsgBehavior)
            })
            .As <IWeChatEventBehavior>();
        }