Please help me to write test class for event object. I am getting only 25% code coverage.  // Method to validate start and End Time on events     public static void ValidateStartEndTime(List&lt;Event&gt; evts) {         for(Event ev: evts)         {             if(ev.StartDateTime.time() &lt; Time.newInstance(7, 30, 0, 0))             {                 ev.StartDateTime.addError('Start time should be greater than or equals to 7:30 AM');             }             if(ev.EndDateTime.time() &gt; Time.newInstance(18, 00, 0, 0))             {                 ev.EndDateTime.addError('End time should be less than or equals to 6 PM');             }         }     }   Test class:  @isTest public class EventTrigger_Test {      static testMethod void myUnitTest1(){          Event e = new Event();         e.StartDateTime=system.today();         e.EndDateTime=system.today()+5;          Test.startTest();               insert e;         Test.stopTest();     } }
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 is code coverage obtained and calculated? How do I increase my coverage?  Why can't I cover these lines? Why isn't the body of my loop or conditional statement covered?
Some guy called one of my Snipplr submissions "crap" because I used if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of if ($_POST)  Checking the request method seems more correct to me because that's what I really want to do. Is there some operational difference between the two or is this just a code clarity issue? Is there any way to actually impose disadvantage (not just cancel advantage) on saving throws against spells for a creature with Magic Resistance? Many creatures in D&amp;D 5e have a feature called Magic Resistance. One such is the :  Magic Resistance. The archmage has advantage on saving throws against spells and other magical effects.  So the Archmage has advantage on saving throws against magical effects. Suppose I wanted to weaken the Archmage's resistance to magic - I use some effect that gives disadvantage on the saving throw for my spell. Normally, this would balance out to a straight roll, as the  say:  If circumstances cause a roll to have both advantage and disadvantage, you are considered to have neither of them, and you roll one d20. This is true even if multiple circumstances impose disadvantage and only one grants advantage or vice versa. In such a situation, you have neither advantage nor disadvantage.  This seems to set a baseline for a straight roll on saves against magical effects, that the Archmage can never roll at disadvantage against magical effects. But is there a way to get around this? Keep in mind, such an ability must respect the  rule:  That said, many racial traits, class features, spells, magic items, monster abilities, and other game elements break the general rules in some way, creating an exception to how the rest of the game works. Remember this: If a specific rule contradicts a general rule, the specific rule wins.  The general rule here is that advantage and disadvantage balance out to a single die roll, so getting around Magic Resistance must either specifically override the rule for advantage and disadvantage, or eliminate Magic Resistance entirely. Is there any way (e.g. magic item, class feature, spell, etc.) to force a creature with Magic Resistance to make a save against a magical effect with disadvantage?  While writing this up I did find  which asks generally how to combat creatures with Magical Resistance, I intend this to be a (hopefully) more focused version of that question. Prove that a group is infinite and nonabelian. I'm trying to solve a question of Hungerford's Algebra:     Show that the group defined by generators $a,b$ and relations   $a^2=b^3=e$ is infinite and nonabelian.   I guess a good approach would be to find an infinite and nonabelian group with two generators satisfying the same conditions and let Van Dyck do all the work. I've been thinking about the group of permutations $S_{\mathbb N}$, some groups of matrices, but I couldn't get it. Could anyone give me a hint? Thanks in advance! Find Neural Network Inputs Given Outputs I've trained a neural network with two inputs, a single hidden layer with two neurons, and one output using a bipolar sigmoid activation function. If a single input is known, how would I determine the second input to create a desired output?  For example, let's say the neural network is trained to add two inputs to produce an output. So if input_1 = 3 and input_2 = 4, the output will be 7, (3 + 4 = 7). Given input_1 = 3 and the desired output is 7, I want to calculate the second input required to produce the desired output (the answer should be 4).  How would I do this for a network that is more complicated than basic addition and has multiple inputs/outputs? For example, for a network with four inputs and two outputs, how would I calculate input_3 and input_4 given input_1, input_2, output_1 and output_2? Is there any way to keep a command from being added to your history? I have a command that I want to keep out of my history file, and I really don't care to have it there when I search the history stored in memory, though that's less of a concern. Is there any way to prevent this, or do I just have to go back and edit my history file.  update: I didn't realize this might be shell-specific. My shell is zsh. You're welcome to answer for other shells so people know how to do this in their shell. Most efficient method to break Ubuntu future or present with when I just would like to know if this sentence would be grammatically correct and in which cases should I use it:  I don't know when he is back instead of he will be back . I know the rule with when "no will" in most cases but we can say" please let me know when it will be available or when it is available"  If that's not correct let me know why please Validation Rule on picklist under opportunities There are 2 requirements:    standard users can’t update the status of a record beyond “open won” (so that only SF Admins or auto processes update “registered” and the stages beyond registration. Validation rule for this:    ~   AND(       $Profile.Name &lt;&gt; "System Administrator",      ISCHANGED(StageName),      OR(TEXT(StageName) = "Registered",     TEXT(StageName) = "Pre-Certified",     TEXT(StageName) = "Documentation, Submission",     TEXT(StageName) = "Performance verified",     TEXT(StageName) = "Appeals",     TEXT(StageName) = "Certification/ Closed Won")      )   Requirement 2: Standard users cannot update the status of a record that is already Registered (or post-registered phase). For us, some Opp was already “Registered” but some standard user  was able to change the record to “Open Won.”    I am looking for the validation rule of requirement 2 and which should align with first requirement also.  Thanks, Please guide. Geometric intuition for the tensor product of vector spaces How do I upgrade from 14.04 LTS to 16.04.1 LTS? How is the Schroedinger equation a wave equation? How do you carry a dog on a bike? Over the years I have seen a few people transport a dog on a bike.  What options have you seen?   Please include a photo in your answer if possible. How does one solve the matrix equation $AX+XB=C$ for $X$? It doesn't seem too difficult. I tried many times but failed.  I'm an adult student... I am now vexed about Gilbert Strang - An Introduction to Linear Algebra. I don't even understand a single word in Wikipedia: . If you have ever use some nice workable materials or lecture notes? You can generously upload and share the links of the lecture notes and assignments. Different subjects/ topics are welcome, as long as you deem they are nice and workable.   The problem origins from a system of diff equation, using undetermined coefficients (matrix) to find the particular solution. Try $y_p=X\begin{pmatrix}   e^{\alpha t} \\ e^{\beta t} \end{pmatrix}$  $\dot{y}+Ay=C\begin{pmatrix} e^{\alpha t} \\ e^{\beta t}\end{pmatrix}$   $\dot{y_p}=X\begin{pmatrix} \alpha &amp; 0 \\ 0 &amp; \beta \end{pmatrix} \begin{pmatrix}e^{\alpha t} \\ e^{\beta t}\end{pmatrix}$  substitute $\dot{y_p}$ and $y_p$ into the original differential equation..  $X\begin{pmatrix} \alpha &amp; 0 \\ 0 &amp; \beta \end{pmatrix}+AX=C$ so I am creating a few posts about bearings and wheels, (story so far):      I have now got the wheels, bearings and freehub working.  Started riding to work this morning and I almost couldn't stop at a junction.  Thankfully wasn't going too fast.  I physically can not get the wheel to lock.  I have to use both brakes at full force to get the bike to roll to a stop.  If I only use one brake I would not stop at any junction in time.  Could the cause be any of the following:   Over greased bearings? Over greased axle? not tightened cone hubs enough? not tighted axle enough?   I do not have any grease on the disk brakes them selves.  Rather nervous getting on the bike now.  Don't seem to be doing too well with this bike home fixing thing.  over greased bearings?  EDIT  Forgot to mention that it is hydraulic disk brakes.  EDIT 2  So in the end I took it to the LBS as I didn't have much confidence in my self at this point.  They had to replace the front pads but where able to clean the rear and cleaned the rotors.  (I had tried to clean the rotors but obviously not vigorously enough).  He said it was a bit of a pain to do.  All is working again.  They double checked my wheels and said I had put them back together correctly which is reassuring.  Thanks for all the help How to know if Mac OS X machine is being remotely viewed? Making a div vertically scrollable using CSS Why do professional print houses use gamut-limiting CMYK? I recently had some business cards printed, and was warned to use the CMYK colour space if providing TIF files.  When I tried saving from Paint Shop Pro to a CMYK, of course the colours came out very much duller, so I provided a different file type that preserved my colours using RGB. To my horror, the cards came back nevertheless converted to the CMYK dull shades.    A few months previously I had been in a hurry and had printed my own one-sided quasi business cards using glossy photo paper and a cheap home printer.  This reproduced my desired colours perfectly.  Since the whole point of using professional printers is quality (though I admit bulk as well), why do they not use printers that can cope with the RGB colour range?   FYI: the main colour in question, which I chose very carefully, is a slightly yellow-tinged lawn green, which I understand doesn't feature in the CMYK gamut.  So why use that gamut, and is there anything I can do to overcome this issue and get cards printed in the colour I have chosen? How do I make the Super key open the activities overview in Ubuntu 20.04 LTS? I have the Nikon kit lens that came with a D5100 — the kit lens is  . I was thinking of getting a fast lens and I am looking to buy the .  Should I consider 35mm or instead buy a 55-200mm for better range? C# datetime parse issue