Skip to content

Instantly share code, notes, and snippets.

@saicharanreddyk
Created March 22, 2020 06:50
Show Gist options
  • Save saicharanreddyk/cd70de6ded7f9c97079852c78230bccb to your computer and use it in GitHub Desktop.
Save saicharanreddyk/cd70de6ded7f9c97079852c78230bccb to your computer and use it in GitHub Desktop.
AccountServiceTest
@IsTest
private class AccountServiceTest {
@IsTest
static void should_create_account() {
String acctName = 'Salesforce';
String acctNumber = 'SFDC';
String tickerSymbol = 'CRM';
Test.startTest();
AccountService service = new AccountService();
Account newAcct = service.createAccount( acctName, acctNumber, tickerSymbol );
insert newAcct;
Test.stopTest();
List<Account> accts = [ SELECT Id, Name, AccountNumber, TickerSymbol FROM Account WHERE Id = :newAcct.Id ];
System.assertEquals( 1, accts.size(), 'should have found new account' );
System.assertEquals( acctName, accts[0].Name, 'incorrect name' );
System.assertEquals( acctNumber, accts[0].AccountNumber, 'incorrect account number' );
System.assertEquals( tickerSymbol, accts[0].TickerSymbol, 'incorrect ticker symbol' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment