Increase unit-test coverage of fflib_SObject2 to 94%
Signed-off-by: WimVelzeboer <wimvelzeboer@protonmail.com>
This commit is contained in:
@@ -108,8 +108,6 @@ private class fflib_SObjects2Test
|
|||||||
domain.getIdFieldsByIdField(Account.Id, Account.Id);
|
domain.getIdFieldsByIdField(Account.Id, Account.Id);
|
||||||
domain.getIdFieldValues(Account.Id);
|
domain.getIdFieldValues(Account.Id);
|
||||||
domain.getIdFieldValues(Account.Id, criteria);
|
domain.getIdFieldValues(Account.Id, criteria);
|
||||||
domain.getIntegerFieldValues(Account.NumberOfEmployees);
|
|
||||||
domain.getIntegerFieldValues(Account.NumberOfEmployees, criteria);
|
|
||||||
domain.getDecimalFieldValues(Account.BillingLatitude, criteria);
|
domain.getDecimalFieldValues(Account.BillingLatitude, criteria);
|
||||||
domain.getDoubleFieldValues(Account.BillingLatitude);
|
domain.getDoubleFieldValues(Account.BillingLatitude);
|
||||||
domain.getDoubleFieldValues(Account.BillingLatitude, criteria);
|
domain.getDoubleFieldValues(Account.BillingLatitude, criteria);
|
||||||
@@ -144,6 +142,68 @@ private class fflib_SObjects2Test
|
|||||||
System.assertEquals(accountName, result.get(accountId), 'Incorrect returned account name');
|
System.assertEquals(accountName, result.get(accountId), 'Incorrect returned account name');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IsTest
|
||||||
|
static void itShouldReturnIntegerFieldValues()
|
||||||
|
{
|
||||||
|
final Integer numberOfEmployees = 10;
|
||||||
|
final String accountName = 'Test Account';
|
||||||
|
DomainAccounts domain = new DomainAccounts(
|
||||||
|
new List<Account>
|
||||||
|
{
|
||||||
|
new Account(NumberOfEmployees = numberOfEmployees),
|
||||||
|
new Account(Name = accountName, NumberOfEmployees = numberOfEmployees * 2),
|
||||||
|
new Account() // This one should be ignored
|
||||||
|
});
|
||||||
|
|
||||||
|
System.Test.startTest();
|
||||||
|
Set<Integer> result = domain.getIntegerFieldValues(Account.NumberOfEmployees).getIntegerSet();
|
||||||
|
Set<Integer> result2 =
|
||||||
|
domain.getIntegerFieldValues(
|
||||||
|
Account.NumberOfEmployees,
|
||||||
|
new fflib_Criteria().equalTo(Schema.Account.Name, accountName)
|
||||||
|
)
|
||||||
|
.getIntegerSet();
|
||||||
|
System.Test.stopTest();
|
||||||
|
|
||||||
|
System.assertEquals(2, result.size(), 'Incorrect amount of results');
|
||||||
|
System.assert(result.contains(numberOfEmployees), 'The expected numberOfEmployees was not returned');
|
||||||
|
System.assert(result.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||||
|
|
||||||
|
System.assertEquals(1, result2.size(), 'Incorrect amount of results');
|
||||||
|
System.assert(result2.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||||
|
}
|
||||||
|
|
||||||
|
@IsTest
|
||||||
|
static void itShouldReturnLongFieldValues()
|
||||||
|
{
|
||||||
|
final Integer numberOfEmployees = 10;
|
||||||
|
final String accountName = 'Test Account';
|
||||||
|
DomainAccounts domain = new DomainAccounts(
|
||||||
|
new List<Account>
|
||||||
|
{
|
||||||
|
new Account(NumberOfEmployees = numberOfEmployees),
|
||||||
|
new Account(Name = accountName, NumberOfEmployees = numberOfEmployees * 2),
|
||||||
|
new Account() // This one should be ignored
|
||||||
|
});
|
||||||
|
|
||||||
|
System.Test.startTest();
|
||||||
|
Set<Long> result = domain.getLongFieldValues(Account.NumberOfEmployees).getLongSet();
|
||||||
|
Set<Long> result2 =
|
||||||
|
domain.getLongFieldValues(
|
||||||
|
Account.NumberOfEmployees,
|
||||||
|
new fflib_Criteria().equalTo(Schema.Account.Name, accountName)
|
||||||
|
)
|
||||||
|
.getLongSet();
|
||||||
|
System.Test.stopTest();
|
||||||
|
|
||||||
|
System.assertEquals(2, result.size(), 'Incorrect amount of results');
|
||||||
|
System.assert(result.contains(numberOfEmployees), 'The expected numberOfEmployees was not returned');
|
||||||
|
System.assert(result.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||||
|
|
||||||
|
System.assertEquals(1, result2.size(), 'Incorrect amount of results');
|
||||||
|
System.assert(result2.contains(numberOfEmployees * 2), 'The expected numberOfEmployees was not returned');
|
||||||
|
}
|
||||||
|
|
||||||
@IsTest
|
@IsTest
|
||||||
static void itShouldReturnRecordIdById()
|
static void itShouldReturnRecordIdById()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user