Move away from using OptionsSetup in test
This commit is contained in:
parent
84804fec20
commit
3a7917c566
|
|
@ -107,23 +107,16 @@ namespace Microsoft.AspNet.Identity.Test
|
|||
Assert.Equal(1001, options.Lockout.MaxFailedAccessAttempts);
|
||||
}
|
||||
|
||||
public class PasswordsNegativeLengthSetup : ConfigureOptions<IdentityOptions>
|
||||
{
|
||||
public PasswordsNegativeLengthSetup()
|
||||
: base(options => options.Password.RequiredLength = -1)
|
||||
{ }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanCustomizeIdentityOptions()
|
||||
{
|
||||
var services = new ServiceCollection()
|
||||
.ConfigureOptions<PasswordsNegativeLengthSetup>();
|
||||
.Configure<IdentityOptions>(options => options.Password.RequiredLength = -1);
|
||||
services.AddIdentity<TestUser,TestRole>();
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
var setup = serviceProvider.GetRequiredService<IConfigureOptions<IdentityOptions>>();
|
||||
Assert.IsType(typeof(PasswordsNegativeLengthSetup), setup);
|
||||
Assert.NotNull(setup);
|
||||
var optionsGetter = serviceProvider.GetRequiredService<IOptions<IdentityOptions>>();
|
||||
Assert.NotNull(optionsGetter);
|
||||
var myOptions = optionsGetter.Value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue