Skip to content

Instantly share code, notes, and snippets.

@mjgallag
Created March 1, 2012 18:19
Show Gist options
  • Select an option

  • Save mjgallag/1951883 to your computer and use it in GitHub Desktop.

Select an option

Save mjgallag/1951883 to your computer and use it in GitHub Desktop.
BUG FIXED! See All Data Custom Setting Tests
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<customSettingsType>List</customSettingsType>
<customSettingsVisibility>Public</customSettingsVisibility>
<enableFeeds>false</enableFeeds>
<label>See All Data Custom Setting</label>
</CustomObject>
@isTest class SeeAllDataCustomSettingTests {
@isTest (SeeAllData=true) static void trueSeeAllDataCustomSettingTest() {
final SeeAllDataCustomSetting__c seeAllDataCustomSetting = new SeeAllDataCustomSetting__c(Name = 'Name');
System.assertEquals(0, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
System.assertEquals(0, SeeAllDataCustomSetting__c.getAll().size());
insert seeAllDataCustomSetting;
System.assertEquals(1, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
System.assertEquals(1, SeeAllDataCustomSetting__c.getAll().size());
delete seeAllDataCustomSetting;
System.assertEquals(0, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
System.assertEquals(0, SeeAllDataCustomSetting__c.getAll().size());
}
@isTest (SeeAllData=false) static void falseSeeAllDataCustomSettingTest() {
final SeeAllDataCustomSetting__c seeAllDataCustomSetting = new SeeAllDataCustomSetting__c(Name = 'Name');
System.assertEquals(0, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
System.assertEquals(0, SeeAllDataCustomSetting__c.getAll().size());
insert seeAllDataCustomSetting;
System.assertEquals(1, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
System.assertEquals(1, SeeAllDataCustomSetting__c.getAll().size());
delete seeAllDataCustomSetting;
System.assertEquals(0, [SELECT COUNT() FROM SeeAllDataCustomSetting__c]);
// FIXED! BUG: Custom Settings not being flushed from application cache on delete when (SeeAllData=false)
System.assertEquals(0, SeeAllDataCustomSetting__c.getAll().size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment