Skip to content

Commit

Permalink
Started to write and sketch the test for ObjectCache
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Mar 10, 2022
1 parent c743113 commit 776d691
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public with sharing class ObjectCache
String getIdFor( Object objectToGetIdFor );
}

@testVisible
ICacheAdaptor cacheWrapper = new OrgCache(); // by default, configure the cache to use the org version

private final static Integer CACHE_LIFESPAN_SECONDS = 28800; // TODO: soft setting / option
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@isTest
private without sharing class ObjectCacheTest
{
@isTest
private static void constructor_setsTheCacheToOrgCache() // NOPMD: Test method name format
{
Test.startTest();
ObjectCache cache = new ObjectCache();
Test.stopTest();

System.assert( cache.cacheWrapper instanceOf OrgCache, 'constructor, will set the cache to SessionCache' );
}

@isTest
private static void setScope_whenGivenOrg_setsTheCacheToOrgCache() // NOPMD: Test method name format
{

ObjectCache cache = new ObjectCache();

Test.startTest();
cache.setScope( ObjectCache.CacheScope.ORG );
Test.stopTest();

System.assert( cache.cacheWrapper instanceOf OrgCache, 'setScope, when given Org, will set the cache to SessionCache' );
}

@isTest
private static void setScope_whenGivenSession_setsTheCacheToSessionCache() // NOPMD: Test method name format
{

ObjectCache cache = new ObjectCache();

Test.startTest();
cache.setScope( ObjectCache.CacheScope.SESSION );
Test.stopTest();

System.assert( cache.cacheWrapper instanceOf SessionCache, 'setScope, when given SESSION, will set the cache to SessionCache' );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexClass>

0 comments on commit 776d691

Please sign in to comment.