-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kristjan Nielsen
committed
Oct 20, 2023
1 parent
734872d
commit 058b0e1
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
GsaGHTests/1_BaseParameters/5_Results/Quantities/GsaDisplacementQuantityTests.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,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using GsaAPI; | ||
using GsaGH.Components; | ||
using GsaGH.Helpers.GsaApi; | ||
using GsaGH.Parameters; | ||
using GsaGH.Parameters.Results; | ||
using GsaGHTests.Helper; | ||
using OasysUnits; | ||
using Xunit; | ||
using LengthUnit = OasysUnits.Units.LengthUnit; | ||
|
||
namespace GsaGHTests.Parameters.Results { | ||
[Collection("GrasshopperFixture collection")] | ||
public partial class GsaDisplacementQuantityTests { | ||
[Fact] | ||
public void GsaDisplacementQuantityConstructorTest() { | ||
var apiResult = new Double6(1.1, 2.2, 3.3, 4.4, 5.5, 6.6); | ||
var displacementQuantity = new GsaDisplacementQuantity(apiResult); | ||
Assert.Equal(apiResult.X, displacementQuantity.X.Meters); | ||
Assert.Equal(apiResult.Y, displacementQuantity.Y.Meters); | ||
Assert.Equal(apiResult.Z, displacementQuantity.Z.Meters); | ||
|
||
double lPyth = Math.Sqrt((1.1 * 1.1) + (2.2 * 2.2) + (3.3 * 3.3)); | ||
Assert.Equal(lPyth, displacementQuantity.Xyz.Meters); | ||
|
||
Assert.Equal(apiResult.XX, displacementQuantity.Xx.Radians); | ||
Assert.Equal(apiResult.YY, displacementQuantity.Yy.Radians); | ||
Assert.Equal(apiResult.ZZ, displacementQuantity.Zz.Radians); | ||
|
||
double aPyth = Math.Sqrt((4.4 * 4.4) + (5.5 * 5.5) + (6.6 * 6.6)); | ||
Assert.Equal(aPyth, displacementQuantity.Xxyyzz.Radians); | ||
} | ||
|
||
[Fact] | ||
public void GsaDisplacementQuantityAngleNanTest() { | ||
var apiResult = new Double6(1.1, 2.2, 3.3, double.NaN, double.NaN, double.NaN); | ||
var displacementQuantity = new GsaDisplacementQuantity(apiResult); | ||
|
||
Assert.Equal(Angle.Zero, displacementQuantity.Xx); | ||
Assert.Equal(Angle.Zero, displacementQuantity.Yy); | ||
Assert.Equal(Angle.Zero, displacementQuantity.Zz); | ||
Assert.Equal(Angle.Zero, displacementQuantity.Xxyyzz); | ||
} | ||
|
||
[Fact] | ||
public void GsaDisplacementQuantityAngleInfinityTest() { | ||
var apiResult = new Double6(1.1, 2.2, 3.3, double.PositiveInfinity, double.NegativeInfinity, double.NaN); | ||
var displacementQuantity = new GsaDisplacementQuantity(apiResult); | ||
|
||
Assert.Equal(360, displacementQuantity.Xx.Degrees); | ||
Assert.Equal(-360, displacementQuantity.Yy.Degrees); | ||
Assert.Equal(Angle.Zero, displacementQuantity.Zz); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
GsaGHTests/1_BaseParameters/5_Results/Quantities/ResultUtilityTests.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,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.IO; | ||
using System.Linq; | ||
using GsaAPI; | ||
using GsaGH.Components; | ||
using GsaGH.Helpers.GsaApi; | ||
using GsaGH.Parameters; | ||
using GsaGH.Parameters.Results; | ||
using GsaGHTests.Helper; | ||
using OasysUnits; | ||
using Xunit; | ||
using LengthUnit = OasysUnits.Units.LengthUnit; | ||
|
||
namespace GsaGHTests.Parameters.Results { | ||
public partial class ResultUtilityTests { | ||
[Theory] | ||
[InlineData(2.0, 3.0, 4.0, LengthUnit.Millimeter)] | ||
public void PythagoreanQuadrupleTest(double a, double b, double c, Enum unit) { | ||
IQuantity x = Quantity.From(a, unit); | ||
IQuantity y = Quantity.From(b, unit); | ||
IQuantity z = Quantity.From(c, unit); | ||
IQuantity quantity = ResultUtility.PythagoreanQuadruple(x, y, z, unit); | ||
|
||
double pyth = Math.Sqrt((a * a) + (b * b) + (c * c)); | ||
IQuantity expected = Quantity.From(pyth, unit); | ||
|
||
Assert.Equal(expected.Value, quantity.Value); | ||
Assert.Equal(expected.Unit, quantity.Unit); | ||
Assert.Equal(expected, quantity); | ||
} | ||
} | ||
} |