public void Can_Update_User_By_Updating_The_UserName_Property_Expecting_Success() { var variableToken = DateTime.Now.ToLongTimeString(); var username = "******"; const string email = "*****@*****.**"; const string woFs = "myTwoFactorSecret"; const string pwd = "password"; const string updatedUserName = "******"; _uow = new SimpleMembershipUnitOfWorkAsync(_dataContextAsync, _loggingService); _simpleMembershipService = new WebSecurity(_uow, _loggingService); if (!_simpleMembershipService.FoundUser(username)) { var token = _simpleMembershipService.CreateUserAndAccount(username, pwd, email, true); CreatedTestUsers.Add(username); Assert.IsNotNull(token, "Token for selected username: [ " + username + " ] was *null*. "); } var userProfileOriginal = _simpleMembershipService.GetUserByUserName(username); var originalOne = userProfileOriginal.RowVersion; Assert.IsNotNull(userProfileOriginal, "Could *not* find the user account by user name: [ " + username + " ], before the update. "); userProfileOriginal.UserName = updatedUserName; var isUpdated = _simpleMembershipService.UpdateUser(userProfileOriginal); Assert.IsNotNull(isUpdated, "The user: [ " + userProfileOriginal.UserName + " ] was *not* updated. "); var userProfileAfterTheUpdate = _simpleMembershipService.GetUserByUserName(updatedUserName); // We expect to find that this users enitity was indeed updated... Assert.IsNotNull(userProfileAfterTheUpdate, "Could *not* find the user account by user name: [ " + updatedUserName + " ] after the update. "); Assert.AreEqual(updatedUserName, userProfileAfterTheUpdate.UserName, "User Names after update do *not* match. Expected: [ " + updatedUserName + "], but instead found: [ " + userProfileAfterTheUpdate.UserName.Trim() + " ]. "); }
public void Can_Get_User_By_UserName_Expecting_UserName() { var variableToken = DateTime.Now.ToLongTimeString(); const string username = "******"; const string email = "*****@*****.**"; const string woFs = "myTwoFactorSecret"; const string pwd = "password"; if (!_simpleMembershipService.FoundUser(username)) { var token = _simpleMembershipService.CreateUserAndAccount(username, pwd, email, true); CreatedTestUsers.Add(username); Assert.IsNotNull(token, "Token for selected username: [ " + username + " ] was *null*. "); } var actualUser = _simpleMembershipService.GetUserByUserName(username); // Expecting to find the user entity that has the requested user name... Assert.AreEqual(username, actualUser.UserName, "User names do not match. Expected: [ " + username + " ], but instead found: [ " + actualUser.UserName.Trim() + " ]. "); }