Please Let me know.How to write TEST class for the following code?  trigger TriggerForACC on Account (before insert) {     List&lt;Contact&gt; conUpdatedList=new List&lt;Contact&gt;();      List&lt;Contact&gt; ExistingList=[Select Id,Name FROM Contact];     for(Account acc: Trigger.New){         acc.Name='MyAccount';         acc.BillingCity='Bangalore';         acc.BillingCountry='India';     }     for(Contact cont:ExistingList){         cont.FirstName='Kavya';         conUpdatedList.add(cont);     }     update conUpdatedList;  }
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.
How do I study the "correlation" between a continuous variable and a categorical variable? How to add a confirm dialog to a command button? I'd think this would work just fine, but it seems to prevent the action function from firing regardless of the confirm response  &lt;apex:commandButton value="Remove All" action="{!removeAll}" rerender="form"      status="LoadingStatus" onclick="return confirm('Are you sure?');"/&gt; Let $H$ be a subgroup of $G$ with $[G:H]=n$ and $G$ finite.  Let $G$ act on left cosets of $H$ by left multiplication.  Let $N$ be the kernel of the action.  Show that $[G:N]$ divides $n!$.  Ok so I have a theorem that says that if $G$ is simple then it embeds into $S_n$.  So if $G$ is simple than I'm done because $G$ divides $n!$ and thus $N$ divides $n!$ and hence $[G:N]$ divides $n!$.  Now I also know that $N$ is the largest normal subgroup of $G$ contained in $H$.  Thus if $G$ isn't simple then it contains some non-trivial normal subgroup $K$ and thus $K\cap H$ is normal in $H$ and by the 2nd Iso Theorem $H/K\cap H\cong KH/H$...    As you can see I'm not sure where to go from here. I was hoping to prove that $K\cap H$ wasn't trivial and thus that $N$ couldn't be trivial since it must contain $K\cap H$, but I'm not sure I can, and even if I could I'm not sure that would help me in showing that $[G:N]$ is small enough to divide $n!$.  Can anyone give some guidance?  Thanks. Outcast boy meets girl underwater E: dpkg was interrupted... run 'sudo dpkg --configure -a' I was running an upgrade with the apt-get command, and it was taking an exceptionally long time because half way through my ISP hit me in the face with their fair usage policy.   After sitting outside &amp; watching the rain for awhile my electronics regained consciousness, so I went back to complete the upgrade and my terminal scolds me with   "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem."   The last bit of legible info was all this:  Installing (ri/RDoc) documention for (stuff and such) ERROR:  Could not find a valid gem 'watobo-0.9.8.724.gem' (&gt;= 0) in any repository rm: cannot remove `watobo-0.9.8.724.gem': No such file or directory  Setting up metasploit (4.3.0-bt1) ... Upgrading Pre-Existing Installation... /opt/metasploit/postgresql/scripts/ctl.sh : postgresql  (pid 1191) already running prosvc is running metasploit is running [*] [*] Attempting to update the Metasploit Framework... [*]   So on it goes for miles, talking about gem caches, rubies, &amp; stuff I wish I had. All up until:  A    lib/gemcache/ruby/1.9.1/gems/state_machine-1.1.2/gemfiles/active_record-2.1.2.gemfile.lock   ...and there it has sat, all night.    If I stop it, will I still get the dpkg error (on the off chance that I won't), or if so what do I need to to resume using apt-get commands and its Super Cow Powers? avidemux problems with Ubuntu 16.04 LTS I installed 16.04 a few days ago and had to reinstall some apps. One of them was avidemux. After I installed it from the Software Center, I couldn't get it to work properly. It wouldn't even load a video clip before giving me an error message and closing.   After trying many commands to purge the avidemux files, I still can't get it to reinstall from the Software Center...   Any tips? Wedge product and change of variables In sampling without replacement the probability of any fixed element in the population to be included in a random sample of size $r$ is $\frac{r}{n}$. In sampling with replacement the corresponding probability is $\left[1- \left(\frac{1}{1-n}\right)^r\right]$.  Please help me show how this is proved. I'm asked to used induction to prove Bernoulli's Inequality: If $1+x&gt;0$, then $(1+x)^n\geq 1+nx$ for all $n\in\mathbb{N}$. This what I have so far:  Let $n=1$. Then $1+x\geq 1+x$. This is true. Now assume that the proposed inequality holds for some arbitrary $k$, namely that $$1+x&gt;0\implies (1+x)^k\geq 1+kx,~\forall~k\in\mathbb{N}\setminus\{1\}$$ is true. We want to show that the proposed inequality holds for $k+1$. Thus multiplication of $(1+x)$ on each side of the above inequality produces the following result: $$(1+x)(1+x)^k\geq (1+kx)(1+x)\implies (1+x)^{k+1}\geq 1+x+kx+kx^2\cdots\cdots\cdots$$  I'm not sure where to go from here. How to set programmatically multiple arguments for views contextual filters How to set programmatically multiple arguments for views contextual filters?  I can do it with one argument, it works great, but not with multiple arguments.  I want to select all nodes created by a list of people, but views only takes first in array into consideration:  $array = array(3250,32); $view = views_get_view('myview'); $view-&gt;set_display("myblock"); $view-&gt;set_arguments($array); $view-&gt;pre_execute(); $view-&gt;execute(); $content = $view-&gt;render();    Am I doing something wrong? Showing that $ \sum_{n=1}^{\infty} \arctan \left( \frac{2}{n^2} \right) =\frac{3\pi}{4}$ Value of having done applied math research when applying to PhD programs in pure math I will be a second year math under-grad in September, and currently doing an internship at applied math research institute. Most probably, I will come up with a research paper at the end of the internship.  However, my interest after my bachelors is to do PhD in pure math from a top math school.My question is this:     Would the admission committee consider my current research since it is in applied math?    In addition, if anyone can suggest me some ideas on how can I bridge the gap between my paper in applied math and my interest in analysis, I would be extremely grateful.  P.S.:  is a related but different question also of mine. Calculating optimal number of bins in a histogram I'm interested in finding as optimal of a method as I can for determining how many bins I should use in a histogram. My data should range from 30 to 350 objects at most, and in particular I'm trying to apply thresholding (like Otsu's method) where "good" objects, which I should have fewer of and should be more spread out, are separated from "bad" objects, which should be more dense in value. A concrete value would have a score of 1-10 for each object. I'd had 5-10 objects with scores 6-10, and 20-25 objects with scores 1-4. I'd like to find a histogram binning pattern that generally allows something like Otsu's method to threshold off the low scoring objects. However, in the implementation of Otsu's I've seen, the bin size was 256, and often I have many fewer data points that 256, which to me suggests that 256 is not a good bin number. With so few data, what approaches should I take to calculating the number of bins to use? Grep: unexpected results when searching for words in heading from man page I'm running into weird behavior when trying to grep a man page on macOS. For example, the Bash man page clearly has an occurrence of the string NAME:  $ man bash | head -5 | tail -1 NAME   And if I grep for name I do get results, but if I grep for NAME I don't:  $ man bash | grep 'NAME' $ man bash | grep NAME   I've tried other uppercase words that I know are in there, and searching for SHELL yields nothing whereas searching for BASH yields results.  What's going on here?  Update: Thanks for all the answers! I thought it worth adding the context in which I ran into this. I wanted to write a bash function to wrap man and in cases where I've tried to look up the man page for a shell builtin, jump to the relevant section of the Bash man page. There might be a better way, but here's what I've got currently:  man () {   case "$(type -t "$1")" in     builtin)       local pattern="^ *$1"        if bashdoc_match "$pattern \+[-[]"; then         command man bash | less --pattern="$pattern +[-[]"       elif bashdoc_match "$pattern\b"; then         command man bash | less --pattern="$pattern[[:&gt;:]]"       else         command man bash       fi       ;;     keyword)       command man bash | less --hilite-search --pattern='^SHELL GRAMMAR$'       ;;     *)       command man "$@"       ;;   esac }  bashdoc_match() {   command man bash | col -b | grep -l "$1" &gt; /dev/null } Layover at Narita, Japan. Do I need a transit visa? Using "nor" in a list without "neither" This is the classic usage of neither/nor:     I would neither hide nor run away.   But is the following construction grammatical? (More than two choices, no neither)     I wasn't going to play dead.   I wasn't going to hide.   Nor was I going to run away. Attempt to de-reference a null object: Trigger There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was:      Apex trigger updatequotestatus caused an unexpected exception, contact your administrator: updatequotestatus: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.updatequotestatus line 5, column 1.   Error Occured at Line:     if((t.what.getsobjecttype() == quote__c.sobjecttype) &amp;&amp; (t.subject.substring(0,5) == 'Email')  trigger updatequotestatus on task (after insert, after update){     Set&lt;Id&gt; quoteIds = new Set&lt;Id&gt;();     List&lt;quote__c&gt; quotes = new List&lt;quote__c&gt;();      for(task t:trigger.new){         if(t.whatId!=null){             if((t.what.getsobjecttype() == quote__c.sobjecttype) &amp;&amp; (t.subject.substring(0,5) == 'Email')){                 quoteIds.add(t.whatId);             }         }     }      for(quote__c q:[select StageName__c from quote__c where Id IN : quoteIds]){         quote__c qt = new quote__c();         qt.Id = q.Id;         qt.StageName__c = 'Proposal Sent';         quotes.add(qt);     }      if(quotes.size()&gt;0){         update quotes;     } } Objects not rotating or scaling in viewport How to pipe output from one process to another but only execute if the first has output? How can I rewrite this command to only email if there is output from the mailq | grep?  mailq | egrep 'rejected|refused' -A 5 -B 5 | mail -s 'dd' email@email   Is this even possible on one line?  See  for a more general case than sending email. Is there anyway I can connect resistors to allow them to take more power such as using 4 1/4 watt resistors to get a 1 watt resistors. Or do i just have to use 1 1 Watt resistor.