コード例 #1
0
 public async void GetAccountingUserByEmailOrUserNameWithEmailShouldReturnAnUser()
 {
     var runner = new TestRunner(services => services.Configure<IdentityOptions>(options =>
     {
         options.Password.RequireUppercase = false;
         options.Password.RequireNonLetterOrDigit = false;
         options.Password.RequireDigit = false;
     }));
     string id = string.Empty;
     await runner.Setup(async (context, next) =>
     {
         var userManager = context.ApplicationServices.GetService<UserManager<AccountingUser>>();
         var user = new AccountingUser { UserName = TestUserNameOne, Email = TestUserEmailOne };
         var result = await userManager.CreateAsync(user, TestPassword);
         if (result.Succeeded)
         {
             id = (await userManager.FindByNameAsync(TestUserNameOne)).Id;
         }
     })
     .Test((context, next) =>
     {
         var userRepo = context.ApplicationServices.GetService<AccountUserRepository>();
         var user = userRepo.GetAccountingUserByEmailOrUserName(TestUserEmailOne);
         user.Should().NotBeNull();
         user.Id.Should().BeEquivalentTo(id);
         return Task.FromResult(0);
     })
     .Run();
 }
コード例 #2
0
 public async void DoesEmailExistReturnFalse()
 {
     var runner = new TestRunner(services => services.Configure<IdentityOptions>(options =>
     {
         options.Password.RequireUppercase = false;
         options.Password.RequireNonLetterOrDigit = false;
         options.Password.RequireDigit = false;
     }));
     string id = string.Empty;
     await runner.Setup((context, next) => { return Task.FromResult(0); }).Test((context, next) =>
     {
         var userRepo = context.ApplicationServices.GetService<AccountUserRepository>();
         var result = userRepo.DoesEmailExist(TestUserNameOne);
         result.Should().BeFalse();
         return Task.FromResult(0);
     })
     .Run();
 }
コード例 #3
0
 public async void DoesUsernameExistReturnTrue()
 {
     var runner = new TestRunner(services => services.Configure<IdentityOptions>(options =>
     {
         options.Password.RequireUppercase = false;
         options.Password.RequireNonLetterOrDigit = false;
         options.Password.RequireDigit = false;
     }));
     string id = string.Empty;
     await runner.Setup(async (context, next) =>
     {
         var userManager = context.ApplicationServices.GetService<UserManager<AccountingUser>>();
         var user = new AccountingUser { UserName = TestUserNameOne, Email = TestUserEmailOne };
         var result = await userManager.CreateAsync(user, TestPassword);              
     })
     .Test((context, next) =>
     {
         var userRepo = context.ApplicationServices.GetService<AccountUserRepository>();
         var result = userRepo.DoesUsernameExist(TestUserNameOne);
         result.Should().BeTrue();
         return Task.FromResult(0);
     })
     .Run();
 }