public void Create_DataCorrect_ReferralCreated() { var user = UserFaker.Create(); var referral = UserFaker.Create(); UserReferralRepository.Create(user, referral); var invitedUsers = UserReferralRepository.GetInvited(referral); Assert.AreEqual(invitedUsers[0].referral_id, referral.id); }
public static UserModel FindOrCreateByEmailAndLogin( string email, string login, string password = null, UserModel referral = null ) { password ??= Rand.RandomString(); var user = UserModel.FindByEmail(email); var loginUser = UserModel.FindByLogin(login); var baseLogin = login; int postfixNum = 0; while (loginUser != null) { postfixNum++; login = $"{baseLogin}_{postfixNum}"; loginUser = UserModel.FindByLogin(login); } user ??= Create(email, login, password); UserBadge.Create(user, "Early adopter"); int tokenRegisterBonus = System.Convert.ToInt32( AppConfig.GetConfiguration("user:registration:token_bonus") ); if (tokenRegisterBonus > 0) { UserBalance.Create(user, CurrencyType.GitComToken, tokenRegisterBonus); FundingTransaction.Create( user, user.id, EntityType.User, null, tokenRegisterBonus, CurrencyType.GitComToken ); } if (referral != null) { UserReferralRepository.Create(user, referral); } return(user); }