|
| 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 | +} |
0 commit comments