Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dcarroll's full-sized avatar

Dave Carroll dcarroll

View GitHub Profile
@isTest
private class TestCleanUpBatchClass {
static testmethod void test() {
// The query used by the batch job.
String query = 'SELECT Id,CreatedDate FROM Merchandise__c ' +
'WHERE Id NOT IN (SELECT Merchandise__c FROM Line_Item__c)';
// Create some test merchandise items to be deleted by the batch job.
Warehouse__c w = new Warehouse__c(
Name='Warehouse 1',
@isTest
private class TestInvoiceStatementDeletion {
static testmethod void TestDeleteInvoiceWithLineItem() {
// Create an invoice with a line item then try to delete it
Invoice__c inv = TestDataFactory.createOneInvoiceStatement(true);
Test.startTest();
Database.DeleteResult result = Database.delete(inv, false);
Test.stopTest();
// Verify invoice with a line item didn't get deleted.
System.assert(!result.isSuccess());
@isTest
public class TestDataFactory {
public static Invoice__c createOneInvoiceStatement(Boolean withLineItem) {
// Create Warehouse if one does not exist
Warehouse__c w;
List<Warehouse__c> warehouse = [SELECT ID from Warehouse__c];
if(warehouse.size() == 0) {
w = createWarehouseLocation('Warehouse 1');
} else {
w = warehouse[0];
@dcarroll
dcarroll / GoInstant Web RTC Sample
Created February 24, 2014 20:46
Working sample of using GoInstant Web RTC Chat and Video Widget.
<!-- visStyles Static resource for CSS styles -->
.gi-override {
position: relative;
}
.webrtc-container {
position: relative;
float: left;
width: 559px;
height: 420px;
@dcarroll
dcarroll / gist:8427394
Created January 14, 2014 22:42
Javascript operations for Visualforce Remote Objects. Totally subject to change as this feature is currently in Developer Preview until Summer '14.
/* PRE - model declaration on vf page
<apex:remoteObjects>
<apex:remoteObjectModel name="Account" fields="Id,Name" />
</apex:remoteObjects>
*/
/* INSTANCE */
// 1. W/o default properties
var acc = new SObjectModel.Account();