コード例 #1
0
        public void Init()
        {
            _user  = CreateUser("123");
            _props = new AuthenticationProperties();

            var services = new ServiceCollection();

            services.AddSingleton <IAuthenticationService>(MockHelpers.CreateMockAuthenticationService().Object);
            services.AddAuthentication(auth =>
            {
                auth.DefaultAuthenticateScheme = "foo";
            });

            _mockHttpContextAccessor           = MockHelpers.CreateMockHttpContextAccessor(services);
            _mockAuthenticationSchemeProvider  = MockHelpers.CreateMockAuthenticationSchemeProvider();
            _mockAuthenticationHandler         = MockHelpers.CreateMockAuthenticationHandler();
            _mockAuthenticationHandlerProvider = MockHelpers.CreateMockAuthenticationHandlerProvider(_mockAuthenticationHandler.Object);

            _subject = new SharedUserSession(
                _mockHttpContextAccessor.Object,
                _mockAuthenticationSchemeProvider.Object,
                _mockAuthenticationHandlerProvider.Object,
                _anonOptions,
                MockHelpers.CreateMockSystemClock().Object);
        }