function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vemanath reddyvemanath reddy 

hello,how to cover below code

hello,

please help me how to
cover below code

 public void AccountSummaryExcdisable()
    {
        ReportTypes = 'PDF';
        Divisionlists = 'All';
        Countrylists = 'All';
        Timeslot = Timeslot;
        
        Schdate=Reportlibrary.ReportlibDateField__c;
        Schdate= System.Today();
        Reportlibrary.ReportlibDateField__c=Schdate;
        
        if(AWDNo != null || AWDNo !='')
        {
            DiscountNumber=AWDNo;
            Brands = 'Avis';
        }
        else if((AWDNo == null || AWDNo =='') && (BCDNo !=null))
        {
            DiscountNumber=BCDNo;
            Brands = 'Budget';
        }
        else if((AWDNo == null || AWDNo =='') && (BCDNo == null || BCDNo =='') && (PDNNo !=null))
        {
            DiscountNumber=PDNNo;
            Brands = 'Payless';         
        }           
        
        DiscountType = AcctDiscounttype;
        IataNumber = null;
        DateRangeFilter = 'Last 30 Days';
        
        /////////////////////////////////Check if an Account is globally mapped or not ///////////////////////////////
        
        if(Brands =='Avis')
        {
            ValidateBrand ='A' ;
            Disctno=AWDNo;
        }
        else if(Brands =='Budget')
        {
            ValidateBrand = 'B';
            Disctno=BCDNo;
        }
        else if(Brands =='Payless')
        {
            ValidateBrand = 'P';
            Disctno=PDNNo;    
        }
        
        System.debug('--Check brand--'+Brands);
        
        System.debug('Check the discount no---- on brand change---'+PDNNo);
        
        System.debug('--Check buildup--'+Disctno);
        
        
        if(Usrs == 'Corporate Account'||Usrs == 'Small Business Account' ||Usrs=='Partnership Account' || Userprof == 'Customer Community Plus Login User' || Userprof == 'Avis_Customer Community Plus'|| Usrs=='Corporate Account')
        {
            ABG_AccountGloballyMapped Globalmap=new ABG_AccountGloballyMapped();
            Globallymapped=Globalmap.Globallymapped;
            Globallymappedno=Globalmap.Globallymappedno;
            System.debug('Check the Globallymapped after ::'+Globallymapped);
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        
        System.debug('onchaneg Discount number---'+DiscountNumber);
        CustomSdate = SchedCussdate.Custom_Start_Date__c;
        CustomSdate=System.Today().AddDays(-92);
        SchedCussdate.Custom_Start_Date__c=CustomSdate;
        CustomEdate = SchedCusEdate.Custom_End_Date__c;
        CustomEdate = System.Today();
        SchedCusEdate.Custom_End_Date__c = CustomEdate;
        
        
        
        if(ReportTile =='Account Summary Snapshot')
        {    
            DisableFlds = false;
            
            Disabledaterange = false;
            Disabledates=true;
            IataDisable = false;
            CustomSdate = SchedCussdate.Custom_Start_Date__c;
            CustomSdate=System.Today().addYears(-1);
            SchedCussdate.Custom_Start_Date__c=CustomSdate;
            CustomEdate = SchedCusEdate.Custom_End_Date__c;
            CustomEdate = System.Today();
            SchedCusEdate.Custom_End_Date__c = CustomEdate;
            
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
            
        }
        else if(ReportTile == 'Pending Reservation Report')
        {
            DateRangeFilter = 'Forward 30 Days';
            Disabledates=true;
            IataDisable = false;
            DisableFlds = false; 
            Disabledaterange = false;
            
            CustomSdate = SchedCussdate.Custom_Start_Date__c;
            CustomSdate=System.Today();
            SchedCussdate.Custom_Start_Date__c=CustomSdate;
            CustomEdate = SchedCusEdate.Custom_End_Date__c;
            CustomEdate = System.Today().AddDays(92);
            SchedCusEdate.Custom_End_Date__c = CustomEdate;
            
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
        }
        else if(ReportTile == 'On Rent Reservation Detail')
        {
            Disabledates=false;  
            IataDisable = false;   
            DisableFlds = false;  
            DateRangeFilter = '';
            
            Disabledaterange = false;             
            
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }           
        }
        else if( ReportTile =='Business Rewards Summary' || ReportTile == 'Enrollment Report')
        {
            Disabledates=true; 
            IataDisable = true;
            DisableFlds = false;
            
            Disabledaterange = false;
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
            
        }
        else if(ReportTile == 'Email Domain Report')
        {
            DateRangeFilter = 'Last 30 Days';
            IataDisable = true;
            DisableFlds = true;
            
            Disabledaterange = true;
            DisableDiscountno = true;
            if(EmailDomain == null || EmailDomain =='')
            {
                DisableSchdReportbutton = true;
            }
            else
            {
                DisableSchdReportbutton = false;
            }
        }
        else if(Usrs =='STC'&& ReportTile == 'Rebate Report')
        {
            DiscountType ='Buildup';
            IataDisable = true;
            DisableFlds = true;
            Disabledaterange = false;
            DisableDiscountno = false;
        }
        else
        {
            DisableFlds = false;
            
            Disabledaterange = false;
            IataDisable = false;
            Disabledates=true;
            System.debug('Heloouser---'+DiscountNumber);
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
        }
        
        if(ReportTile=='Email Domain Report'||ReportTile=='Toll Report'|| ReportTile=='Rebate Report')
        {
            ReportTypes = 'Excel';
        }
        else
        {
            ReportTypes = 'PDF';
        }
        
        if(Usrs == 'Corporate Account'||Usrs == 'Small Business Account' || Usrs=='Partnership Account')
        {
            if(DiscountType == 'All Data')
            {
                if(AWDNo != null && AWDNo !='')
                {
                    DiscountNumber=AWDNo;
                    Brands = 'Avis';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo !=null))
                {
                    DiscountNumber=BCDNo;
                    Brands = 'Budget';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo == null || BCDNo =='') && (PDNNo !=null))
                {
                    DiscountNumber=PDNNo;
                    Brands = 'Payless';         
                }           
                
            }
            else if(DiscountType == 'Stem' || DiscountType == 'Divisional')
            {
                DiscountNumber=null;
                DisableDiscountno = false;
                if(AcctDiscounttype =='Divisional' && DiscountType =='Divisional')
                {
                    DiscountNumber=AWDNo;
                    System.debug('Check the  AcctDiscounttype :: Divisional ---'+AcctDiscounttype);
                    DisableDiscountno =true;
                }
                else if(AcctDiscounttype =='Stem' &&  DiscountType == 'Stem')
                {
                    System.debug('Check the  AcctDiscounttype :: Stem ---'+AcctDiscounttype);
                    DiscountNumber=AWDNo;
                    DisableDiscountno =true;
                }
                
            }
            else if(DiscountType =='Buildup')
            {
                System.debug('Check the AWDNo no -----'+AWDNo);
                if(AWDNo != null && AWDNo !='')
                {
                    System.debug('----------- AWDNo ----------');
                    DiscountNumber=AWDNo;
                    Brands = 'Avis';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo !=null))
                {
                    System.debug('----------- BCDNo ----------');
                    DiscountNumber=BCDNo;
                    Brands = 'Budget';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo == null || BCDNo =='') && (PDNNo !=null))
                {
                    System.debug('----------- PDN ----------');
                    DiscountNumber=PDNNo;
                    Brands = 'Payless';         
                }   
                //Account is globally mapped build will be unfreezed
                if(Globallymapped == true)
                {
                    DisableDiscountno=false;
                }
                else if(Globallymapped ==false)
                {
                    DisableDiscountno=true;
                }   
            }
            else
            {
                DisableDiscountno=true;
            }
        }
        else if(Usrs == 'Admin'||Usrs == 'HQ')
        {
            DiscountNumber=null;
            if(ReportTile == 'Email Domain Report')
            {
                DisableDiscountno = true;
            }
            else
            {
                DisableDiscountno = false;
            }
            if(ReportTile == 'Rebate Report')
            {
                DiscountType ='Buildup';
                IataDisable = true;
                DisableFlds = true;
                Disabledaterange = false;
                DisableDiscountno = false;
            }
            
        }
        else if(Usrs =='STC')
        {
            if(ReportTile == 'Rebate Report'){
                
                DiscountType = 'Buildup';
            }
            else{
                
                DiscountType = 'All Data';
            }
            if(ReportTile == 'Email Domain Report')
            {
                DisableDiscountno = true;
                
            }
            else
            {
                if(DiscountType == 'Stem' || DiscountType == 'Divisional'|| DiscountType =='Buildup')
                {
                    DiscountNumber=null;
                    DisableDiscountno = false;
                }
                else
                {
                    DiscountNumber = UserDiscountno;
                    DisableDiscountno = true;
                }
            }
            
        }
        
        checkbox = false;
        DisableFrequency = false;
        DisableDays = false;
        disableInput = false;
        CustomdisableInput = false;
        TimeSlotDisable = false;
        DisableName = false;
        
        if(schtype == true)
        {
            DisableFrequency = true;
            DisableDays = true;
        }
        else if(Recurrence == true)
        {
            DisableFrequency = false;
            DisableDays = true;
        }
        
        if(ReportTile =='Account Summary Snapshot')
        {
            
            CustomSdate = SchedCussdate.Custom_Start_Date__c;
            CustomSdate=System.Today().addYears(-1);
            SchedCussdate.Custom_Start_Date__c=CustomSdate;
            CustomEdate = SchedCusEdate.Custom_End_Date__c;
            CustomEdate = System.Today();
            SchedCusEdate.Custom_End_Date__c = CustomEdate;
            
        }
        
        ButtonDisableAndEnable();    
    }

 
pconpcon
Since writing a test class to cover all of the facets of this class is not something that anyone on here will do for you, I can give you some pointers and hopefully get you started.  I would recommend that you do some reading on testing [1] [2] [3] [4] to get a better understanding.  Each of your individual tests should only tests one specific portion of you class (ie a constructor test, sendEmail test, contactSelected test, etc).  You should also have both a postitive (everything works perfectly) and a negative (things are not right) test.

Each test should follow the following structure:
     Setup of test data. This includes creation of any data needed by your class.  Account, Contacts etc
     Starting the test. This is calling Test.startTest() to reset the governor limits
     Calling your class / method
     Stopping the test.This is calling Test.stopTest() to reset the governor limits and allow for any async jobs to finish
     Asserting that your changes have worked
          If you have inserted/updated/deleted data, you need to query for the updates
          Run System.assert, System.assertEquals, System.assertNotEquals to verify that you got the correct data back

If you have any specific problems with your tests, feel free to create a new post with the part of the class you are trying to test and your current test method, and you will more likely get a better response then asking for someone to essentially write an entire test class for you.

NOTE: When adding code please use the "Add a code sample" button (icon <>) to increase readability and make it easier to reference.

[1] http://www.sfdc99.com/2013/05/14/how-to-write-a-test-class/
[2] http://pcon.github.io/presentations/testing/
[3] http://blog.deadlypenguin.com/blog/2014/07/23/intro-to-apex-auto-converting-leads-in-a-trigger/
[4] http://blog.deadlypenguin.com/blog/testing/strategies/