@isTest
public with sharing class TestUserExample {
  
      
        @isTest static void itWorks() {
            System.runAs(new User(Id = UserInfo.getUserId())){
                 createUser(); 
            }
            User user = [SELECT Id FROM User WHERE UserName LIKE 'admin%' LIMIT 1];
            //query user 
            //
            //createAccount();
      
        }
      
        private static void createAccount(){
            String random = String.valueof(DateTime.now().getTime());
        
            Account acc = new Account(Name = random);
            acc.CurrencyIsoCode = 'USD';
            acc.BillingCity = 'New York';
            acc.BillingCountry = 'United States';
            acc.BillingState = 'New York';
            acc.BillingStreet = 'abc 1234';
            acc.Website = 'www.google.com';
        
            insert ACC;
      
        }
      
        private static void createUser(){
            String random = String.valueof(DateTime.now().getTime());
        
            Profile profile = [SELECT Id FROM Profile WHERE Name='系统管理员'];
        
            User user = new User();
            user.Email = 'random@random.com'+random;
            user.UserName = 'admin@random.com'+random;
            user.LastName = 'random'+random;
            user.Alias = 'random';
            user.ProfileId = profile.Id;
            user.EmailEncodingKey='UTF-8';
            user.LanguageLocaleKey='en_US';
            user.LocaleSidKey='en_US';
            user.TimeZoneSidKey = 'America/Los_Angeles';
        
            insert user;
        }
}