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

                    IdentityServices.AddPasswords(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IPasswordHasher>());
                    Assert.True(provider.GetRequiredService <IPasswordHasher>() is Pbkdf2PasswordHasher);
                }
Пример #3
0
                public void WhenCalled_AddsMinimumLengthPasswordStrengthValidator()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddPasswords(services);

                    var provider = services.BuildServiceProvider();

                    var validators = provider.GetRequiredService <IEnumerable <IPasswordStrengthValidator> >();

                    Assert.NotNull(validators);
                    Assert.Single(validators);
                    Assert.True(validators.First() is MinimumLengthPasswordStrengthValidator);
                }
Пример #4
0
                public void WhenCalled_AddsIUserHelper()
                {
                    var services = Services();

                    IdentityServices.AddInfrastructure(services);
                    IdentityServices.AddPasswords(services);
                    IdentityServices.AddUserEmailStore <User, FakeUserEmailStore>(services);
                    IdentityServices.AddSingleUseTokenService <FakeSingleUseTokenService>(
                        services);
                    IdentityServices.AddTimedLockoutStore <FakeTimedLockoutStore>(services);

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

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IUserHelper>());
                    Assert.True(provider.GetRequiredService <IUserHelper>() is UserHelper <User>);
                }
Пример #5
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>);
                }