Skip to content

Commit

Permalink
Add AngleRevolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmada committed Nov 16, 2019
1 parent 794ea70 commit a4bdf45
Show file tree
Hide file tree
Showing 16 changed files with 1,795 additions and 205 deletions.
104 changes: 14 additions & 90 deletions NetFabric.Angle.UnitTests/AngleDegreesTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentAssertions;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
Expand All @@ -11,96 +12,6 @@ public class AngleDegreesTests
{
static readonly AngleDegrees AcuteAngle = AngleDegrees.Right / 2.0;

public static TheoryData<int, double, AngleDegrees> AngleDegreesMinutesData = new TheoryData<int, double, AngleDegrees>
{
{ 40, 0.0, Angle.FromDegrees(40) },
{ -40, 0.0, Angle.FromDegrees(-40) },
{ 40, 30.0, Angle.FromDegrees(40.5) },
{ -40, 30.0, Angle.FromDegrees(-40.5) },
};

[Theory]
[MemberData(nameof(AngleDegreesMinutesData))]
public void ToDegrees_When_AngleMinutes_Should_Succeed(int degrees, double minutes, AngleDegrees expected)
{
// arrange

// act
var angle = Angle.FromDegrees(degrees, minutes);

// assert
angle.Degrees.Should().BeApproximately(expected.Degrees, 0.0001);
}

public static TheoryData<int, int, double, AngleDegrees> AngleDegreesMinutesSecondsData = new TheoryData<int, int, double, AngleDegrees>
{
{ 40, 0, 0.0, Angle.FromDegrees(40) },
{ -40, 0, 0.0, Angle.FromDegrees(-40) },
{ 40, 30, 30.0, Angle.FromDegrees(40.50833) },
{ -40, 30, 30.0, Angle.FromDegrees(-40.50833) },
};

[Theory]
[MemberData(nameof(AngleDegreesMinutesSecondsData))]
public void ToDegrees_When_AngleMinutesSeconds_Should_Succeed(int degrees, int minutes, double seconds, AngleDegrees expected)
{
// arrange

// act
var angle = Angle.FromDegrees(degrees, minutes, seconds);

// assert
angle.Degrees.Should().BeApproximately(expected.Degrees, 0.0001);
}

public static TheoryData<AngleRadians, AngleDegrees> AngleRadiansData = new TheoryData<AngleRadians, AngleDegrees>
{
{ -AngleRadians.Full, -AngleDegrees.Full },
{ -AngleRadians.Straight, -AngleDegrees.Straight },
{ -AngleRadians.Right, -AngleDegrees.Right },
{ AngleRadians.Zero, AngleDegrees.Zero },
{ AngleRadians.Right, AngleDegrees.Right },
{ AngleRadians.Straight, AngleDegrees.Straight },
{ AngleRadians.Full, AngleDegrees.Full },
};

[Theory]
[MemberData(nameof(AngleRadiansData))]
public void ToDegrees_When_AngleRadians_Should_Succeed(AngleRadians value, AngleDegrees expected)
{
// arrange

// act
var angle = Angle.ToDegrees(value);

// assert
angle.Should().BeOfType<AngleDegrees>().And.Be(expected);
}

public static TheoryData<AngleGradians, AngleDegrees> AngleGradiansData = new TheoryData<AngleGradians, AngleDegrees>
{
{ -AngleGradians.Full, -AngleDegrees.Full },
{ -AngleGradians.Straight, -AngleDegrees.Straight },
{ -AngleGradians.Right, -AngleDegrees.Right },
{ AngleGradians.Zero, AngleDegrees.Zero },
{ AngleGradians.Right, AngleDegrees.Right },
{ AngleGradians.Straight, AngleDegrees.Straight },
{ AngleGradians.Full, AngleDegrees.Full },
};

[Theory]
[MemberData(nameof(AngleGradiansData))]
public void ToDegrees_When_AngleGradians_Should_Succeed(AngleGradians value, AngleDegrees expected)
{
// arrange

// act
var angle = Angle.ToDegrees(value);

// assert
angle.Should().BeOfType<AngleDegrees>().And.Be(expected);
}

public static TheoryData<AngleDegrees> SerializableData = new TheoryData<AngleDegrees>
{
-AngleDegrees.Full,
Expand Down Expand Up @@ -178,6 +89,7 @@ public void Serializable_Should_Succeed(AngleDegrees angle)
[Theory]
[MemberData(nameof(CompareInvalidData))]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void EqualsObject_Should_Succeed(AngleDegrees left, object right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -191,6 +103,7 @@ public void EqualsObject_Should_Succeed(AngleDegrees left, object right, bool le

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void Equals_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -204,6 +117,7 @@ public void Equals_Should_Succeed(AngleDegrees left, AngleDegrees right, bool le

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void GetHashCode_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -220,6 +134,7 @@ public void GetHashCode_Should_Succeed(AngleDegrees left, AngleDegrees right, bo

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void OperatorEquality_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -233,6 +148,7 @@ public void OperatorEquality_Should_Succeed(AngleDegrees left, AngleDegrees righ

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void OperatorInequality_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -246,6 +162,7 @@ public void OperatorInequality_Should_Succeed(AngleDegrees left, AngleDegrees ri

[Theory]
[MemberData(nameof(CompareInvalidData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void CompareTo_When_InvalidData_Should_Thrown(AngleDegrees angle, object obj, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -261,6 +178,7 @@ public void CompareTo_When_InvalidData_Should_Thrown(AngleDegrees angle, object

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void CompareTo_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -279,6 +197,7 @@ public void CompareTo_Should_Succeed(AngleDegrees left, AngleDegrees right, bool

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void Compare_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -297,6 +216,7 @@ public void Compare_Should_Succeed(AngleDegrees left, AngleDegrees right, bool l

[Theory]
[MemberData(nameof(CompareReducedData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void CompareReduced_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -315,6 +235,7 @@ public void CompareReduced_Should_Succeed(AngleDegrees left, AngleDegrees right,

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void LessThan_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -328,6 +249,7 @@ public void LessThan_Should_Succeed(AngleDegrees left, AngleDegrees right, bool

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void LessThanOrEqual_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -341,6 +263,7 @@ public void LessThanOrEqual_Should_Succeed(AngleDegrees left, AngleDegrees right

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void GreaterThan_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -354,6 +277,7 @@ public void GreaterThan_Should_Succeed(AngleDegrees left, AngleDegrees right, bo

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void GreaterThanOrEqual_Should_Succeed(AngleDegrees left, AngleDegrees right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand Down
62 changes: 14 additions & 48 deletions NetFabric.Angle.UnitTests/AngleGradiansTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentAssertions;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
Expand All @@ -11,54 +12,6 @@ public class AngleGradiansTests
{
static readonly AngleGradians AcuteAngle = AngleGradians.Right / 2.0;

public static TheoryData<AngleRadians, AngleGradians> AngleRadiansData = new TheoryData<AngleRadians, AngleGradians>
{
{ -AngleRadians.Full, -AngleGradians.Full },
{ -AngleRadians.Straight, -AngleGradians.Straight },
{ -AngleRadians.Right, -AngleGradians.Right },
{ AngleRadians.Zero, AngleGradians.Zero },
{ AngleRadians.Right, AngleGradians.Right },
{ AngleRadians.Straight, AngleGradians.Straight },
{ AngleRadians.Full, AngleGradians.Full },
};

[Theory]
[MemberData(nameof(AngleRadiansData))]
public void ToGradians_When_AngleRadians_Should_Succeed(AngleRadians value, AngleGradians expected)
{
// arrange

// act
var angle = Angle.ToGradians(value);

// assert
angle.Should().BeOfType<AngleGradians>().And.Be(expected);
}

public static TheoryData<AngleDegrees, AngleGradians> AngleDegreesData = new TheoryData<AngleDegrees, AngleGradians>
{
{ -AngleDegrees.Full, -AngleGradians.Full },
{ -AngleDegrees.Straight, -AngleGradians.Straight },
{ -AngleDegrees.Right, -AngleGradians.Right },
{ AngleDegrees.Zero, AngleGradians.Zero },
{ AngleDegrees.Right, AngleGradians.Right },
{ AngleDegrees.Straight, AngleGradians.Straight },
{ AngleDegrees.Full, AngleGradians.Full },
};

[Theory]
[MemberData(nameof(AngleDegreesData))]
public void ToGradians_When_AngleDegrees_Should_Succeed(AngleDegrees value, AngleGradians expected)
{
// arrange

// act
var angle = Angle.ToGradians(value);

// assert
angle.Should().BeOfType<AngleGradians>().And.Be(expected);
}

public static TheoryData<AngleGradians> SerializableData = new TheoryData<AngleGradians>
{
-AngleGradians.Full,
Expand Down Expand Up @@ -126,6 +79,7 @@ public void Serializable_Should_Succeed(AngleGradians angle)
[Theory]
[MemberData(nameof(CompareInvalidData))]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void EqualsObject_Should_Succeed(AngleGradians left, object right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -139,6 +93,7 @@ public void EqualsObject_Should_Succeed(AngleGradians left, object right, bool l

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void Equals_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -152,6 +107,7 @@ public void Equals_Should_Succeed(AngleGradians left, AngleGradians right, bool

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void GetHashCode_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -168,6 +124,7 @@ public void GetHashCode_Should_Succeed(AngleGradians left, AngleGradians right,

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void OperatorEquality_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -181,6 +138,7 @@ public void OperatorEquality_Should_Succeed(AngleGradians left, AngleGradians ri

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void OperatorInequality_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -194,6 +152,7 @@ public void OperatorInequality_Should_Succeed(AngleGradians left, AngleGradians

[Theory]
[MemberData(nameof(CompareInvalidData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void CompareTo_When_InvalidData_Should_Thrown(AngleGradians angle, object obj, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -209,6 +168,7 @@ public void CompareTo_When_InvalidData_Should_Thrown(AngleGradians angle, object

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void CompareTo_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -227,6 +187,7 @@ public void CompareTo_Should_Succeed(AngleGradians left, AngleGradians right, bo

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void Compare_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -245,6 +206,7 @@ public void Compare_Should_Succeed(AngleGradians left, AngleGradians right, bool

[Theory]
[MemberData(nameof(CompareReducedData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void CompareReduced_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -263,6 +225,7 @@ public void CompareReduced_Should_Succeed(AngleGradians left, AngleGradians righ

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void LessThan_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -276,6 +239,7 @@ public void LessThan_Should_Succeed(AngleGradians left, AngleGradians right, boo

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void LessThanOrEqual_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -289,6 +253,7 @@ public void LessThanOrEqual_Should_Succeed(AngleGradians left, AngleGradians rig

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void GreaterThan_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand All @@ -302,6 +267,7 @@ public void GreaterThan_Should_Succeed(AngleGradians left, AngleGradians right,

[Theory]
[MemberData(nameof(CompareData))]
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public void GreaterThanOrEqual_Should_Succeed(AngleGradians left, AngleGradians right, bool lessThan, bool equal, bool greaterThan)
{
// arrange
Expand Down
Loading

0 comments on commit a4bdf45

Please sign in to comment.