• praveen naraharisetty
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
please help with dis test class


public with sharing class CalendarController {


  public String selectedEvent{get;set;}
  public String selectedEventName{get;set;}
  
  public Date selectedEventStartDate{get;set;}
  public String selectedEventDescription{get;set;}
  
  public String selectedStartDateStr{get;set;}
  public String customerId{get;set;}
  public String customerName{get;set;}
  
  public String contactId{get;set;}
  public String contactName{get;set;}
  
  public Event eventObject{get;set;}
  
  public void next() { 
    addMonth(1);
  }

  public void prev() { 
    addMonth(-1); 
  }

  public CalendarController() {
   eventObject = new Event();
   Date d = system.today();  // default to today 
   Integer mo = d.month(); 
   String m_param = System.currentPageReference().getParameters().get('mo');
   String y_param = System.currentPageReference().getParameters().get('yr');
   
   // allow a month to be passed in on the url as mo=10
   if (m_param != null) { 
        Integer mi = Integer.valueOf(m_param); 
        if (mi > 0 && mi <= 12) {
          d = Date.newInstance(d.year(),mi,d.day());
        }
   }
   // and year as yr=2008
   if (y_param != null) { 
        Integer yr = Integer.valueOf(y_param); 
        d = Date.newInstance(yr, d.month(), d.day());
   }

   setMonth(d);
  }
  public Month getMonth() { return month; }  
  public List<Month.Week> getWeeks() { 
    system.assert(month!=null,'month is null');
    return month.getWeeks();
  }
  
 


  private void setMonth(Date d) { 
    month = new Month(d);  
    system.assert(month != null); 

    Date[] da = month.getValidDateRange();  // gather events that fall in this month
    events = [ select id,subject,WhatId,whoId,description,StartDateTime,activitydate,activitydatetime,DurationInMinutes
        from Event 
        where OwnerId =: userinfo.getuserid() AND activitydate >= :da[0] AND activityDate <= :da[1]
        order by activitydatetime];

    month.setEvents(events);  // merge those events into the month class
  }
  
  private void addMonth(Integer val) { 
    Date d = month.getFirstDate();
    d = d.addMonths(val);
    setMonth(d);
  }

  private List<Event> events;
  private Month month;
  
  public string getFormTag() {
    return System.currentPageReference().getParameters().get('frm');
  }

  // used by the visualforce page to send the link to the right dom element for the text box
  public string getTextBox() {
    return System.currentPageReference().getParameters().get('txt');
  }
  
   public PageReference processLinkClick() {
       Event ev = [ select id,subject,WhatId,whoId,description,StartDateTime,activitydate,activitydatetime,DurationInMinutes from Event where id=:selectedEvent];
       selectedEventStartDate = date.newinstance(ev.StartDateTime.year(), ev.StartDateTime.month(), ev.StartDateTime.day());
       //selectedStartDateStr = ev.StartDateTime.format('MM/dd/yyyy');
       
       selectedStartDateStr = LocaleFormatedDateTimeController.getTimeZoneValue(ev.StartDateTime);
       
       //customerId = ev.whatId;
       if(ev.whatId != null){
       Account acc = [Select name from  Account where id=: ev.whatId];
       //customerName = acc.Name;
       }
       
       //contactId = ev.whoId;
       
       if(ev.whoId != null){
       Contact con = [Select name, Account.Name, AccountId from  Contact where id=: ev.whoId];
       customerId = con.AccountId;
       customerName = con.Account.Name;
       
       }
       
       return null;
    }

}



test class


@isTest
Private class testCalendarController{
static testmethod void main(){
Apexpages.currentpage().getParameters().put('mo',12);
Apexpages.currentpage().getParameters().put('yr',2014);
CalendarController c = new CalendarController();
c.setMonth(System.today());
c.getFormTag();
c.getTextBox();
}
}



 
i have is_active__C checkbox on account object. so my requirment is on visualforce page i want to take one check box as 'show active accounts only'.when ever its checked i want to show active accounts only(which account checked while creating account record).otherwise show all accounts


on vf page i created one chekbok with name show active accounts and have one command button get accounts. if the chekbox is checked i want to show only active accounts

I am not undestanding where we use system.assert() and system.assertEquals() and how it is working

please give me explanation with an example