Skip to content

Commit

Permalink
Added a test for NullCache
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Mar 10, 2022
1 parent c60ecc3 commit 3906e1a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* An implementation of the ICacheAdaptor that is benign.
* An implementation of the ICacheAdaptor that is benign - conforms to the Null Object Pattern
*
* Allows for the use of code that will automatically interact with a cache and be able to switch that off dynamically and simply.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@isTest
private without sharing class NullCacheTest
{
@isTest
private static void hasAccessToCache_whenCalled_returnsTrue() // NOPMD: Test method name format
{
Boolean got = new NullCache().hasAccessToCache();
System.assertEquals( true, got, 'hasAccessToCache, when called, will return true' );
}

@isTest
private static void isACache_whenCalled_returnsFalse() // NOPMD: Test method name format
{
Boolean got = new NullCache().isACache();
System.assertEquals( false, got, 'hasAccessToCache, when called, will return false' );
}

@isTest
private static void get_whenCalled_returnsNull() // NOPMD: Test method name format
{
Object got = new NullCache().get( null );
System.assertEquals( null, got, 'get, when called, will return null' );
}

@isTest
private static void put_whenCalled_doesNothing() // NOPMD: Test method name format
{
new NullCache().put( null, null, null );
System.assert( true, 'put, when called, will do nothing and not throw an exception' );
}

@isTest
private static void contains_whenCalled_returnsFalse() // NOPMD: Test method name format
{
Boolean got = new NullCache().contains( null );
System.assertEquals( false, got, 'contains, when called, will return false' );
}

@isTest
private static void remove_whenCalled_doesNothing() // NOPMD: Test method name format
{
new NullCache().remove( null );
System.assert( true, 'remove, when called, will do nothing and not throw an exception' );
}
}
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 3906e1a

Please sign in to comment.