It just compiled a simple test, and not for any specific reason, except I wanted to try the tests for all my methods, although this is pretty simple, or so I thought.
[TestMethod] public void Test_GetToolRating() { var rating = GetToolRating(45.5, 0); Assert.IsNotNull(rating); } private static ToolRating GetToolRating(double total, int numberOf) { var ratingNumber = 0.0; try { var tot = total / numberOf; ratingNumber = Math.Round(tot, 2); } catch (Exception ex) { var errorMessage = ex.Message;
As you can see in the testing method, I divide by zero. The problem is that it does not generate an error. See Error Window Screen below.

Instead of error, does it give the meaning of infinity? What am I missing? So I searched googled and found that doubles divided by zero DO NOT generate an error, they either give zero or infinity. The question then becomes, how is one test for the return value of Infinity?
c # divide-by-zero
dinotom May 30 '17 at 9:14 a.m. 2017-05-30 09:14
source share