public void BasicProperties_Assigned()
 {
     var sub = new MockUserAccount("ten", "user", "pass", "email");
     var now = new DateTime(2000, 2, 3, 8, 30, 0);
     sub.Setup(x => x.UtcNow).Returns(now);
     Assert.AreEqual("ten", sub.Object.Tenant);
     Assert.AreEqual("user", sub.Object.Username);
     Assert.AreEqual("email", sub.Object.Email);
     Assert.AreEqual(now, sub.Object.Created);
     sub.Verify(x => x.SetPassword("pass"));
 }
 public void CallsAuthenticateOnUserAccount()
 {
     var sub = new MockUserAccountService();
     var account = new MockUserAccount();
     sub.Object.Authenticate(account.Object, "pass", 10, TimeSpan.FromDays(1));
     account.Verify(x => x.Authenticate("pass", 10, TimeSpan.FromDays(1)));
 }
            public void AllowAccountDeletionDisabled_AccountIsVerified_CallsCloseOnAccount()
            {
                SecuritySettings.Instance.AllowAccountDeletion = false;

                var sub = new MockUserAccountService();
                var account = new MockUserAccount();
                account.Object.IsLoginAllowed = true;
                account.Object.IsAccountVerified = true;
                sub.Object.DeleteAccount(account.Object);

                sub.UserAccountRepository.Verify(x => x.Remove(account.Object), Times.Never());
                account.Verify(x => x.CloseAccount());
            }
            public void Success_CallsVerifyAccountOnUserAccountAndSaveOnRepository()
            {
                var sub = new MockUserAccountService();
                var account = new MockUserAccount();
                sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);

                sub.Object.VerifyAccount("key");

                account.Verify(x => x.VerifyAccount("key"));
                sub.UserAccountRepository.Verify(x => x.SaveChanges());
            }
 public void UserAccountChangeEmailFromKeyCalled()
 {
     var sub = new MockUserAccountService();
     var account = new MockUserAccount();
     sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
     sub.Mock.Setup(x => x.Authenticate(It.IsAny<UserAccount>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<TimeSpan>())).Returns(true);
     sub.Object.ChangeEmailFromKey("pass", "key", "*****@*****.**");
     account.Verify(x => x.ChangeEmailFromKey("key", "*****@*****.**"));
 }
 public void AccountFound_CallsUserAccountChangeEmailRequest()
 {
     var sub = new MockUserAccountService();
     var account = new MockUserAccount();
     sub.Mock.Setup(x => x.GetByUsername(It.IsAny<string>(), It.IsAny<string>())).Returns(account.Object);
     sub.Object.ChangeEmailRequest("user", "*****@*****.**");
     account.Verify(x => x.ChangeEmailRequest("*****@*****.**"));
 }
 public void ChangePasswordFromResetKeyCalledOnUserAccount()
 {
     var sub = new MockUserAccountService();
     var account = new MockUserAccount();
     sub.Mock.Setup(x => x.GetByVerificationKey(It.IsAny<string>())).Returns(account.Object);
     sub.Object.ChangePasswordFromResetKey("key", "new");
     account.Verify(x => x.ChangePasswordFromResetKey("key", "new"));
 }
 public void AccountVerified_UserAccountResetPasswordCalled()
 {
     var sub = new MockUserAccountService();
     var account = new MockUserAccount();
     sub.Mock.Setup(x => x.GetByEmail(It.IsAny<string>(), It.IsAny<string>())).Returns(account.Object);
     account.Object.IsAccountVerified = true;
     sub.Object.ResetPassword("email");
     account.Verify(x => x.ResetPassword());
 }
 public void AccountFound_CallsAccountChangePassword()
 {
     var sub = new MockUserAccountService();
     var account = new MockUserAccount();
     sub.Mock.Setup(x => x.GetByUsername(It.IsAny<string>(), It.IsAny<string>())).Returns(account.Object);
     sub.Object.ChangePassword("user", "old", "new");
     account.Verify(x => x.ChangePassword("old", "new", It.IsAny<int>(), It.IsAny<TimeSpan>()));
 }
 public void ChangeSuccess_SetPasswordInvoked()
 {
     var subject = new MockUserAccount();
     subject.Object.IsAccountVerified = true;
     subject.Object.VerificationKey = "key";
     subject.Setup(x => x.IsVerificationKeyStale).Returns(false);
     var result = subject.Object.ChangePasswordFromResetKey("key", "new");
     subject.Verify(x => x.SetPassword("new"));
 }
 public void SuccessfulChangePassword_SetsPassword()
 {
     Mock<UserAccount> subject = new MockUserAccount();
     subject
         .Setup(x => x.Authenticate(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<TimeSpan>()))
         .Returns(true);
     var result = subject.Object.ChangePassword("old", "new", 0, TimeSpan.Zero);
     subject.Verify(x => x.SetPassword("new"));
 }
 public void ValidAccount_CallsAccount()
 {
     SecuritySettings.Instance.DefaultTenant = "tenant";
     var sub = new MockUserAccountService();
     var account = new MockUserAccount("tenant", "user", "pass", "*****@*****.**");
     sub.MockUserAccounts(account.Object);
     var result = sub.Object.IsPasswordExpired("tenant", "user");
     account.Verify(x => x.IsPasswordExpired);
 }
 public void ValidUser_SetPasswordCalled()
 {
     var sub = new MockUserAccountService();
     var user = new MockUserAccount(SecuritySettings.Instance.DefaultTenant, "user", "foo", "*****@*****.**");
     sub.MockUserAccounts(user.Object);
     sub.Object.SetPassword("user", "pass");
     user.Verify(x => x.SetPassword("pass"));
 }
 public void AccountFound_DoesNotSendAccountNameReminder()
 {
     var sub = new MockUserAccountService();
     MockUserAccount account = new MockUserAccount();
     sub.Mock.Setup(x => x.GetByEmail(It.IsAny<string>(), It.IsAny<string>())).Returns(account.Object);
     sub.Object.SendUsernameReminder("email");
     account.Verify(x => x.SendAccountNameReminder());
 }
 public void CallsAuthenticateOnUserAccount()
 {
     var sub = new MockUserAccountService();
     var account = new MockUserAccount();
     sub.Object.Authenticate(account.Object, "pass");
     account.Verify(x => x.Authenticate("pass", It.IsAny<int>(), It.IsAny<TimeSpan>()));
 }