Exemplo n.º 1
0
        private RegistrationService GetRegistrationService()
        {
            var registrationService = RegistrationServiceTests.GetRegistrationService(authRepo: userAuth);
            var request             = RegistrationServiceTests.GetValidRegistration(autoLogin: true);

            registrationService.Post(request);
            return(registrationService);
        }
Exemplo n.º 2
0
        /// <summary>Gets registration service.</summary>
        ///
        /// <param name="userAuthRepository">The user authentication repository.</param>
        /// <param name="oAuthUserSession">  The authentication user session.</param>
        /// <param name="requestContext">    Context for the request.</param>
        ///
        /// <returns>The registration service.</returns>
        public static RegistrationService GetRegistrationService(
            IUserAuthRepository userAuthRepository,
            AuthUserSession oAuthUserSession  = null,
            MockRequestContext requestContext = null)
        {
            if (requestContext == null)
            {
                requestContext = new MockRequestContext();
            }
            if (oAuthUserSession == null)
            {
                oAuthUserSession = requestContext.ReloadSession();
            }

            var httpReq = requestContext.Get <IHttpRequest>();
            var httpRes = requestContext.Get <IHttpResponse>();

            oAuthUserSession.Id = httpRes.CreateSessionId(httpReq);
            httpReq.Items[ServiceExtensions.RequestItemsSessionKey] = oAuthUserSession;

            var mockAppHost = new BasicAppHost {
                Container = requestContext.Container
            };

            requestContext.Container.Register(userAuthRepository);

            var authService = new AuthService {
                RequestContext = requestContext,
            };

            authService.SetResolver(mockAppHost);
            mockAppHost.Register(authService);

            var registrationService = new RegistrationService {
                UserAuthRepo          = userAuthRepository,
                RequestContext        = requestContext,
                RegistrationValidator =
                    new RegistrationValidator {
                    UserAuthRepo = RegistrationServiceTests.GetStubRepo()
                },
            };

            registrationService.SetResolver(mockAppHost);

            return(registrationService);
        }