public void Generated_code_should_be_unique() { // act var service = new RegistrationCodeService(serviceContext); var code1 = service.CreateCode(Username, UserId, CurrentDate); var code2 = service.CreateCode(Username, UserId, CurrentDate.AddMilliseconds(1)); // assert code1.Should().NotBe(code2); }
public ExternalLoginModel( SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, RegistrationCodeService registrationService, ILogger <ExternalLoginModel> logger) { _signInManager = signInManager; _userManager = userManager; _registrationService = registrationService; _logger = logger; }
public void Generated_code_should_be_saved() { // act var service = new RegistrationCodeService(serviceContext); var code = service.CreateCode(Username, UserId, CurrentDate); // assert code.Should().NotBeEmpty(); var codeEntity = db.RegistrationCodes.FirstOrDefault(x => x.Code == code); codeEntity.Should().NotBeNull(); codeEntity.IsUsed.Should().BeFalse(); codeEntity.ExpirationDate.Should().BeAfter(CurrentDate); }
public void Registration_code_can_be_used_only_once() { // arrange var service = new RegistrationCodeService(serviceContext); var code = service.CreateCode(Username, UserId, CurrentDate); // act var(userName, userId) = service.GetUserByRegistrationCode(code, CurrentDate); var(userName2, userId2) = service.GetUserByRegistrationCode(code, CurrentDate); // assert userName.Should().Be(Username); userId.Should().Be(UserId); userName2.Should().BeNull(); userId2.Should().Be(default);