• Vipin K 23
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

User-added image


Code base:
@isTest(seeAllData =False)
public class OrderTests {
    
    @testSetup 
    public static void SetupTestData(){
        TestDataFactory.InsertTestData(1);
    }

    Static testmethod void OrderUpdate_UnitTest(){
        Test.startTest();
        Product2 originalproduct = [SELECT Id, Family, Name, Quantity_Ordered__c, Quantity_Remaining__c FROM Product2 LIMIT 1];
        Order od = [SELECT id, Status FROM Order LIMIT 1];
        
        
        od.status = constants.ACTIVATED_ORDER_STATUS;
        Update od;
        
        
        Product2 updatedProduct = [SELECT Family,Id,Name,Quantity_Ordered__c ,Quantity_Remaining__c FROM Product2 WHERE id=:originalproduct.Id LIMIT 1];
        
        TestDataFactory.VerifyQuantityOrdered(originalproduct,updatedProduct,Constants.DEFAULT_ROWS);
        Test.stopTest();
    }
}
Thanks in advance.

User-added image


Code base:
@isTest(seeAllData =False)
public class OrderTests {
    
    @testSetup 
    public static void SetupTestData(){
        TestDataFactory.InsertTestData(1);
    }

    Static testmethod void OrderUpdate_UnitTest(){
        Test.startTest();
        Product2 originalproduct = [SELECT Id, Family, Name, Quantity_Ordered__c, Quantity_Remaining__c FROM Product2 LIMIT 1];
        Order od = [SELECT id, Status FROM Order LIMIT 1];
        
        
        od.status = constants.ACTIVATED_ORDER_STATUS;
        Update od;
        
        
        Product2 updatedProduct = [SELECT Family,Id,Name,Quantity_Ordered__c ,Quantity_Remaining__c FROM Product2 WHERE id=:originalproduct.Id LIMIT 1];
        
        TestDataFactory.VerifyQuantityOrdered(originalproduct,updatedProduct,Constants.DEFAULT_ROWS);
        Test.stopTest();
    }
}
Thanks in advance.