Пример #1
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddUserStore <User, FakeUserStore>(services: null);
     });
 }
Пример #2
0
                public void WhenCalled_AddsCrudStore()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddUserStore <User, FakeUserStore>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <ICrudStore <UserKey, User> >());
                }
Пример #3
0
                public void WhenCalled_AddsAuthenticationService()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddOptions(services, new IdentityOptions());
                    IdentityServices.AddInfrastructure(services);
                    IdentityServices.AddUserStore <User, FakeUserStore>(services);

                    // Act
                    IdentityServices.AddUserClaims <User>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IAuthenticationService <ClaimsPrincipal> >());
                    Assert.True(provider.GetRequiredService <IAuthenticationService <ClaimsPrincipal> >() is ClaimsAuthenticationService <User>);
                }
Пример #4
0
                public void NotNullServices_AddsIIdentityService()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddOptions(services, new IdentityOptions());
                    IdentityServices.AddInfrastructure(services);
                    IdentityServices.AddPasswords(services);
                    IdentityServices.AddUserHelpers <User>(services);
                    IdentityServices.AddUserValidators <User>(services, new UserOptions());
                    IdentityServices.AddSingleUseTokenService <FakeSingleUseTokenService>(
                        services);
                    IdentityServices.AddTimedLockoutStore <FakeTimedLockoutStore>(services);
                    IdentityServices.AddUserEmailStore <User, FakeUserEmailStore>(services);
                    IdentityServices.AddUserStore <User, FakeUserStore>(services);
                    IdentityServices.AddUserClaims <User>(services);

                    // Act
                    IdentityServices.AddIdentityServices <User>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IIdentityService <User> >());
                    Assert.True(provider.GetRequiredService <IIdentityService <User> >() is IdentityService <User>);
                }