Skip to content

Commit 52ab9db

Browse files
committed
Added test for DeveloperWorkItem domain logic
1 parent fb711ed commit 52ab9db

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

fflib-sample-code/src/classes/Application.cls

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public class Application
3535
Opportunity.SObjectType,
3636
Product2.SObjectType,
3737
PricebookEntry.SObjectType,
38-
OpportunityLineItem.SObjectType });
38+
OpportunityLineItem.SObjectType,
39+
WorkOrder__c.SObjectType,
40+
DeveloperWorkItem__c.SObjectType,
41+
TrainingWorkItem__c.SObjectType,
42+
DesignWorkItem__c.SObjectType });
3943

4044
// Configure and create the ServiceFactory for this Application
4145
public static final fflib_Application.ServiceFactory Service =
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (c), FinancialForce.com, inc
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
* - Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
* - Neither the name of the FinancialForce.com, inc nor the names of its contributors
14+
* may be used to endorse or promote products derived from this software without
15+
* specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20+
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
**/
26+
27+
@isTest
28+
private class DeveloperWorkItemsTest {
29+
30+
static testMethod void whenInsertingDeveloperWorkItemsThenCalcCost() {
31+
32+
// Given
33+
fflib_ISObjectUnitOfWOrk uow = Application.UnitOfWork.newInstance();
34+
WorkOrder__c wo = new WorkOrder__c();
35+
DeveloperWorkItem__c wi = new DeveloperWorkItem__c();
36+
wi.CodingHours__c = 20;
37+
wi.CodeReviewingHours__c = 1;
38+
wi.TechnicalDesignHours__c = 10;
39+
uow.registerNew(wo);
40+
uow.registerNew(wi, DeveloperWorkItem__c.WorkOrder__c, wo);
41+
42+
// When
43+
uow.commitWork();
44+
45+
// Then
46+
System.assertEquals(3100, [select DeveloperCost__c from DeveloperWorkItem__c where Id = :wi.Id].DeveloperCost__c);
47+
}
48+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>37.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>

0 commit comments

Comments
 (0)