internal static void SetUserAccount(this TestContext testContext, UserAccount userAccount) { testContext.Properties.Add("TestUserAccount", userAccount); }
public UserAccount CreateAccount(string email = null, string password = null) { email = string.IsNullOrEmpty(email) ? TestUser.Email : email; password = string.IsNullOrEmpty(password) ? TestUser.Password : password; string hashPwd = HashGenerator.GenerateHash(password); string mobile = RandomGenerator.GenerateRandomNumberString(10); //Since DB mobile number should be unique string firstName = TestUser != null ? TestUser.FirstName : "TestFName"; string lastName = TestUser != null ? TestUser.LastName : "TestLName"; Account account = _accountDataProvider.CreateAccount(email, firstName, lastName, mobile, hashPwd) ?? _accountDataProvider.GetAccount(_accountDataProvider.GetAccountId(email)); if (account != null) { string authenticationId = _authenticationProvider.CreateAuthenticationId(account.AccountId); var testUserAccount = new UserAccount { AccountId = account.AccountId, AuthenticationId = authenticationId }; return testUserAccount; } throw new NullReferenceException("Account could not be created."); }