Skip to content

Commit

Permalink
Added tests for the new getSobjectLocalName
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Apr 21, 2022
1 parent 9534a6f commit e366958
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ private without sharing class SobjectUtilsTest
System.assertEquals( 'Contact', returnedName, 'getSobjectName, when given an SObjectType, will return the API name of it' );
}

@isTest
private static void getSobjectName_whenGivenAnSobjectTypeInLocalNamespace_willReturnTheFullApiNameOfIt() // NOPMD: Test method name format
{
String returnedName = SobjectUtils.getSobjectName( Application_Configuration__mdt.sobjectType );
ortoo_Asserts.assertEndsWith( '__Application_Configuration__mdt', returnedName, 'getSobjectName, when given an SObjectType in the local namespace, will return the fully qualified API name of it' );
}

@isTest
private static void getSobjectName_whenGivenANullSobjectType_willThrowAnException() // NOPMD: Test method name format
{
Expand All @@ -136,6 +143,33 @@ private without sharing class SobjectUtilsTest
ortoo_Asserts.assertContains( 'Attempted to get the name of a null SObjectType', exceptionMessage, 'getSobjectName, when given a null SobjectType, will throw an exception' );
}

@isTest
private static void getSobjectLocalName_whenGivenAnSobjectTypeInLocalNamespace_willReturnTheShortApiNameOfIt() // NOPMD: Test method name format
{
String returnedName = SobjectUtils.getSobjectLocalName( Application_Configuration__mdt.sobjectType );
System.assertEquals( 'Application_Configuration__mdt', returnedName, 'getSobjectLocalName, when given an SObjectType in the local namespace, will return the local API name of it' );
}

@isTest
private static void getSobjectLocalName_whenGivenANullSobjectType_willThrowAnException() // NOPMD: Test method name format
{
SobjectType nullType = null;

Test.startTest();
String exceptionMessage;
try
{
SobjectUtils.getSobjectLocalName( nullType );
}
catch ( Contract.RequiresException e )
{
exceptionMessage = e.getMessage();
}
Test.stopTest();

ortoo_Asserts.assertContains( 'Attempted to get the local name of a null SObjectType', exceptionMessage, 'getSobjectLocalName, when given a null SobjectType, will throw an exception' );
}

@isTest
private static void isCreateable_whenCalled_willReturnIsCreatableOfThatSobject() // NOPMD: Test method name format
{
Expand Down

0 comments on commit e366958

Please sign in to comment.