public class exmaple_Test{
private static String generateRandomString() {
return '' + math.rint( math.random() * 100000 );
}
static testmethod void method1()
{
test.starttest();
System.runAs ( new User(Id = UserInfo.getUserId()) ) {
List<User> u =[select Id from User where PM_Qualified__c=true LIMIT 1];
List<Profile> prf=[SELECT Id, Name FROM Profile where Name='System Administrator'];
User userToCreate = new User();
userToCreate.FirstName= 'Bonface';
userToCreate.LastName = 'Kambona';
userToCreate.Username = 'testUser-' + generateRandomString() + '@test.com';
userToCreate.Email = 'testUser-' + generateRandomString() + '@test.com';
userToCreate.Alias = 'fatty';
userToCreate.ProfileId = prf[0].Id;
userToCreate.TimeZoneSidKey = 'America/New_York';
userToCreate.LocaleSidKey = 'en_US';
userToCreate.EmailEncodingKey = 'UTF-8';
userToCreate.LanguageLocaleKey = 'en_US';
userToCreate.PM_Qualified__c=true;
userToCreate.isactive=true;
insert userToCreate;
}
}
}
No comments:
Post a Comment