I am not able to understand how to write a test cases for this trigger. What the trigger does is, if a new case is created and it has an email in it, then look for a contact that has the same email and associated the contact with the case. trigger CaseEmailToContactEmail on Case (before insert) {          for(Case c : Trigger.New) {         System.debug('Case details: ' + c);         try{             if(c.SuppliedEmail != null){                             Contact con = [Select Id, Name, hed__AlternateEmail__c, Email From Contact Where Email =: c.SuppliedEmail OR hed__AlternateEmail__c =: c.SuppliedEmail ];                 if(con.Id != null ){                     c.ContactId = con.Id;                 } else {                     System.debug('no Contact record found with case email');                 }                          }         } catch(Exception e){             System.debug('Exception occured: ' + e);         }         finally {             System.debug('No email found on case object');         }      }   }
This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through the resources here and use them to shape more specific questions. To browse all canonical questions and answers, including more unit test resources, navigate to the  tag.  This canonical question is intended to address several classes of common questions by providing a quick summary and links to comprehensive resources:   How do I start writing my first unit test?  How do I unit test this code?  I need help writing this unit test.   Salesforce Stack Exchange looks for detailed, specific questions that the community can help you with, and can't write tests on your behalf. We feel that working with the resources below can help you get started, and we encourage you to make an attempt to write your test and return to SFSE with your specific questions when you encounter challenges you can't resolve.
"Baggage" versus "luggage" I have the feeling that luggage is more closely associated with vacation travel, whereas baggage is for general transportation.  Or... are they just exact synonyms? If $x,y$ are positive reals such that $x+y = 2$ show that $x^3y^3(x^3+y^3) \leq 2$.   I thought about working backwards on this one. We can try to prove that $x^3y^3(x^3+y^3) \leq 2$ is true by first realizing that $x^3+y^3 = (x+y)(x^2-xy+y^2)$ and substituting in for $x+y = 2$. We then get $x^3y^3(x^2-xy+y^2) \leq 1$. How do I prove this is true? Recently I came across a debate about whether it's fair to call RAW 'unprocessed' or 'unaltered' sensor data of a DSLR. As far as I know, the analog sensor data is processed into a digital RAW file using the ISO setting, a process during which the Bayer-sensor data is demosaiced as well. However, those are just the necessary steps for saving a digital file while maintaining maximum quality.  Are those assumptions correct? If so, are there any additional steps that need to be performed between the sensor receiving light and the saving of the RAW file? And can those be reasonably be described as an 'alteration' of the sensor data, or is it fair to say that a RAW file holds the unaltered sensor data? Can anyone tell me how Google decides which image to use when it shows an image with the search results (as is the case with mobile search, sometimes)?  If you look at these mobile search results …    … and take the AliExpress.com result as an example, by inspecting  you can see that  used by Google seems to have no special declaration, etc. It is just the first JPG that appears in that page's HTML - so I was thinking maybe that's why it's the image that is used in the Google search results.  However, when you look at these mobile search results …    … and consider the Backpack Billboards result,  reveals that  being used is actually the seventh image declared in the HTML.  So can anyone shed any light on how Google determines which image to be displayed? I would like to know so I can then have control over which image is displayed for my site.  Update / Solution  Thanks to the answers, below, this is the code I have now added to my head HTML in order to get the thumbnail shown in Google when searching for backpack billboards:  &lt;script type="application/ld+json"&gt; {   "@context": "http://schema.org/",   "@type": "Product",   "name": "Regular Backpack Billboard",   "image": [     "https://backpackbillboards.com/wp-content/uploads/2017/12/backpack-billboards-1x1.jpg",     "https://backpackbillboards.com/wp-content/uploads/2017/12/backpack-billboards-4x3.jpg",     "https://backpackbillboards.com/wp-content/uploads/2017/12/backpack-billboards-16x9.jpg"    ],   "description": "Backpack Billboards feature a rechargeable battery which powers the internal LED lights providing a bright illuminated display for up to 8 hours.",   "sku": "BPBB8",   "brand": {     "@type": "Thing",     "name": "Backpack Billboards"   },   "offers": {     "@type": "Offer",     "priceCurrency": "USD",     "price": "299.00",     "priceValidUntil": "2020-11-11",     "itemCondition": "http://schema.org/NewCondition",     "availability": "http://schema.org/InStock",     "seller": {       "@type": "Organization",       "name": "Backpack Billboards"     }   } } &lt;/script&gt; Electric circuits in TeX, LaTeX, and Friends What are some ways to draw electric circuits in TeX systems?  I'm making this community wiki since I haven't found a question related to this.  I was thinking along the lines of . What do you think of that? Other examples are more than welcome, of course. What is the relationship between a chi squared test and test of equal proportions? Suppose that I have three populations with four, mutually exclusive characteristics.  I take random samples from each population and construct a crosstab or frequency table for the characteristics that I am measuring.  Am I correct in saying that:   If I wanted to test whether there is any relationship between the populations and the characteristics (e.g. whether one population has a higher frequency of one of the characteristics), I should run a chi-squared test and see whether the result is significant. If the chi-squared test is significant, it only shows me that there is some relationship between the populations and characteristics, but not how they are related. Furthermore, not all of the characteristics need to be related to the population.  For example, if the different populations have significantly different distributions of characteristics A and B, but not of C and D, then the chi-squared test may still come back as significant. If I wanted to measure whether or not a specific characteristic is affected by the population, then I can run a test for equal proportions (I have seen this called a z-test, or as prop.test() in R) on just that characteristic.   In other words, is it appropriate to use the prop.test() to more accurately determine the nature of a relationship between two sets of categories when the chi-squared test says that there is a significant relationship? How to capture workload from production to replay on test? I want to perform performance testing on my test server.  How can I capture workload from production and replay on my test server?   Basically I'm looking for detailed steps so that I can replay the workload from production to my test environment. Evaluate this power series Evaluate the sum  $$x+\frac{2}{3}x^3+\frac{2}{3}\cdot\frac{4}{5}x^5+\frac{2}{3}\cdot\frac{4}{5}\cdot\frac{6}{7}x^7+\dots$$  Totally no idea. I think this series may related to the $\sin x$ series because of those missing even powers. Another way of writing this series:  $$\sum_{k=0}^{\infty}\frac{(2k)!!}{(2k+1)!!}x^{2k+1}.$$ Make window always on top? How can I resize an ext root partition at runtime? How can I increase the size of the root partition of a system at runtime?   I have a partition that is not allocated after the root partition (which is also ext4), how can I add that unallocated space to the space allocated to the root partition without having to shutdown the server? I've used git clone to make a local copy of a GitHub repository containing a  I'd like to use. The local copy contains all of the source for the program; but as a newbie to Ubuntu, I've no idea of what tools or steps are involved in compiling and installing the driver.   I'd really appreciate if anyone could provide a step-by-step guide? I have a laptop that has Windows 8 which I use for playing Minecraft. However when using the inventory, I have to hold my mouse to drag and pick the items and I don't like that.   I have tried switching mouses but that didn't work, is this possible to fix? This book came out of the 1970s (early 1980's) at the latest. In it the protagonist, a not so diligent student, gets turned on to computer programming and creates (I think..) a weather program.   Eventually he moves on and years later the program contacts him. It has become an AI and he is its creator.  I forget what the setup is post contact which is not helpful at all.. Cannot empty trash I am trying to empty my trash, and it keeps giving me an error message that says,      .Trash can't be opened right now because it's being used by another task...     I have tried restarting my computer, running Finder > Secure Empty Trash everything yields the same result and error message from above. How does one account for the momentum of an absorbed photon? How to save picture to iPhone photo library? Quotient groups of D10 How do I find the groups D10/N where N is the normal subgroups to D10?  I know that the definition is aN for all a $\in$ D10. But I am unsure what the group, for example, D10/ D10 looks like? Any help would be much appreciated. Nothing shows up in the terminal when I type my password I am reading Tom Apostol's Analysis and come across this theorem.   Should $a \leq b$ if $a\leq b+\epsilon$ for all $\epsilon &gt;0$?   I don't doubt the proof in the book but I don't understand the intuition or geometric explanation behind this. Could somebody shed some light on this equation? I just started studying analysis on my own.$\ \ $ How to delete empty folder with thumbs.db without disabling thumbnails I often have problem to delete a folder that contains a thumbs.db file. Also tools like  fail. It seems to be loccked by os for some unknown reason. The only solution i found in the net was to disabling thumbnails in windows but this is a bad workaround isn't it?  Is there a "normal"(or official, supported by MS) way to delete an empty folder that only contains a thumbs.db?