• Travis - GH
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
trigger AccountEmail on Account (before insert) {

    Map<String, Account> accMap = new Map <String, Account>();
    Map<String, Account> exMap = new Map  <String, Account>();
    Map<String, Contact> conMap = new Map <String, Contact>();
    
    for(Account account: Trigger.new){
      accMap.put(account.Email__c, account); //
   }
    
   for(Account acc : [SELECT Name, Email__c, Secondary_Email__c FROM Account WHERE Email__c in: accMap.keySet()]) {
        
       exMap.put(acc.Email__c, acc);   
   }
    
    for(Contact con : [SELECT Email, Secondary_Email__c FROM Contact WHERE Secondary_Email__c in : conMap.keySet()]){
        conMap.put(con.Secondary_Email__c, con);
    }
    
    //eq
 
     for(Account acc : Trigger.new) {
         
         if(exMap.containsKey(acc.Email__c)) {
       
          acc.Email__c.addError('Existed');
      }

         
   }
        
    
     
    
    
}

 
Hi all! I need to write test class for wrapper class coverage. There is my controller:
public class StoreFrontController {
List<DisplayMerchandise> products;
public List<DisplayMerchandise> getProducts() {
if(products == null) {
products = new List<DisplayMerchandise>();
for(Merchandise__c item : [
SELECT Id, Name, Description__c, Price__c, Total_Inventory__c
FROM Merchandise__c]) {
products.add(new DisplayMerchandise(item));
}
}
return products;
}
// Inner class to hold online store details for item
public class DisplayMerchandise {

private Merchandise__c merchandise;
public DisplayMerchandise(Merchandise__c item) {
this.merchandise = item;
}
// Properties for use in the Visualforce view
public String name {
get { return merchandise.Name; }
}
public String description {
get { return merchandise.Description__c; }
}
public Decimal price {
get { return merchandise.Price__c; }
}
public Boolean inStock {
get { return (0 < merchandise.Total_Inventory__c); }
}
public Integer qtyToBuy { get; set; }
}
}
What Unit Test can I do for my inner class ?

Thanx
 
trigger AccountEmail on Account (before insert) {

    Map<String, Account> accMap = new Map <String, Account>();
    Map<String, Account> exMap = new Map  <String, Account>();
    Map<String, Contact> conMap = new Map <String, Contact>();
    
    for(Account account: Trigger.new){
      accMap.put(account.Email__c, account); //
   }
    
   for(Account acc : [SELECT Name, Email__c, Secondary_Email__c FROM Account WHERE Email__c in: accMap.keySet()]) {
        
       exMap.put(acc.Email__c, acc);   
   }
    
    for(Contact con : [SELECT Email, Secondary_Email__c FROM Contact WHERE Secondary_Email__c in : conMap.keySet()]){
        conMap.put(con.Secondary_Email__c, con);
    }
    
    //eq
 
     for(Account acc : Trigger.new) {
         
         if(exMap.containsKey(acc.Email__c)) {
       
          acc.Email__c.addError('Existed');
      }

         
   }
        
    
     
    
    
}

 
Hi all! I need to write test class for wrapper class coverage. There is my controller:
public class StoreFrontController {
List<DisplayMerchandise> products;
public List<DisplayMerchandise> getProducts() {
if(products == null) {
products = new List<DisplayMerchandise>();
for(Merchandise__c item : [
SELECT Id, Name, Description__c, Price__c, Total_Inventory__c
FROM Merchandise__c]) {
products.add(new DisplayMerchandise(item));
}
}
return products;
}
// Inner class to hold online store details for item
public class DisplayMerchandise {

private Merchandise__c merchandise;
public DisplayMerchandise(Merchandise__c item) {
this.merchandise = item;
}
// Properties for use in the Visualforce view
public String name {
get { return merchandise.Name; }
}
public String description {
get { return merchandise.Description__c; }
}
public Decimal price {
get { return merchandise.Price__c; }
}
public Boolean inStock {
get { return (0 < merchandise.Total_Inventory__c); }
}
public Integer qtyToBuy { get; set; }
}
}
What Unit Test can I do for my inner class ?

Thanx