-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test Coverage 99%
- Loading branch information
Showing
7 changed files
with
238 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
|
||
namespace CalculateParameters | ||
{ | ||
public class Coordinates | ||
{ | ||
public double X { get; } | ||
public double Y { get; } | ||
public double Z { get; } | ||
|
||
public Coordinates(double x, double y, double z) | ||
{ | ||
if (double.IsNaN(x)) | ||
throw new ArgumentException("x coordinate cannot be NaN"); | ||
if (double.IsNaN(y)) | ||
throw new ArgumentException("y coordinate cannot be NaN"); | ||
if (double.IsNaN(z)) | ||
throw new ArgumentException("z coordinate cannot be NaN"); | ||
if (double.IsInfinity(x)) | ||
throw new ArithmeticException("x coordinate attained infinity", | ||
new ArgumentOutOfRangeException()); | ||
if (double.IsInfinity(y)) | ||
throw new ArithmeticException("y coordinate attained infinity", | ||
new ArgumentOutOfRangeException()); | ||
if (double.IsInfinity(z)) | ||
throw new ArithmeticException("z coordinate attained infinity", | ||
new ArgumentOutOfRangeException()); | ||
|
||
X = x; | ||
Y = y; | ||
Z = z; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
SCPT/CalculateParameters/Tests/NewtonIterationProcess/CoordinatesTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using CalculateParameters; | ||
using Xunit; | ||
|
||
|
||
public class CoordinatesTests | ||
{ | ||
[Fact] | ||
private void Coordinate_InitCtorInvalidArgumentNaN_ThrowsArgumentException() | ||
{ | ||
double x = double.NaN, y = double.NaN, z = double.NaN; | ||
|
||
Action test = () => new Coordinates(x, y, z); | ||
|
||
Assert.Throws<ArgumentException>(test); | ||
} | ||
|
||
[Fact] | ||
private void Coordinate_InitCtorInvalidArgumentInfinity_ThrowsArithmeticException() | ||
{ | ||
double xPositiveInfinity = double.PositiveInfinity; | ||
double yPositiveInfinity = double.PositiveInfinity; | ||
double zPositiveInfinity = double.PositiveInfinity; | ||
|
||
double xNegativeInfinity = Double.NegativeInfinity; | ||
double yNegativeInfinity = Double.NegativeInfinity; | ||
double zNegativeInfinity = Double.NegativeInfinity; | ||
|
||
Action test1 = () => new Coordinates(xPositiveInfinity, yPositiveInfinity, zPositiveInfinity); | ||
Action test2 = () => new Coordinates(xNegativeInfinity, yNegativeInfinity, zNegativeInfinity); | ||
|
||
Assert.Throws<ArithmeticException>(test1); | ||
Assert.Throws<ArithmeticException>(test2); | ||
} | ||
|
||
[Fact] | ||
private void Coordinate_TryGetXYZProperty_ValidXYZReturnValue() | ||
{ | ||
var xExpected = 235654.242; | ||
var yExpected = 267654.567; | ||
var zExpected = 223654.234; | ||
|
||
var coords = new Coordinates(xExpected, yExpected, zExpected); | ||
|
||
Assert.Equal(xExpected, coords.X); | ||
Assert.Equal(yExpected, coords.Y); | ||
Assert.Equal(zExpected, coords.Z); | ||
} | ||
} |
Oops, something went wrong.