Files
speckle-sharp-sdk/tests/Speckle.Objects.Tests.Unit/Geometry/ArcTests.cs
T
Adam Hathcock 14d959834f Convert to Xunit (#196)
* xunit unit tests

* most pass with formatting

* convert objects to xunit

* remove nunit

* format

* merge fixes

* switch objects to fluent assertions

* update to fluent assertions

* more FA

* convert all to FA

* Format

* Fix tests

* formatting

* hopefully made credential test better

* Catch more specific exception

* use another more specific exception

* Fix tests

* update to xunit

* update packages
2025-01-09 15:32:28 +00:00

79 lines
2.3 KiB
C#

using FluentAssertions;
using Speckle.Objects.Geometry;
using Speckle.Sdk.Common;
using Xunit;
namespace Speckle.Objects.Tests.Unit.Geometry;
public class ArcTests
{
private Plane TestPlaneCounterClockwise =>
new()
{
origin = new Point(0, 0, 0, Units.Meters),
normal = new Vector(0, 0, 1, Units.Meters),
xdir = new Vector(1, 0, 0, Units.Meters),
ydir = new Vector(0, 1, 0, Units.Meters),
units = Units.Meters,
};
private Plane TestPlaneClockwise =>
new()
{
origin = new Point(0, 0, 0, Units.Meters),
normal = new Vector(0, 0, -1, Units.Meters),
xdir = new Vector(-1, 0, 0, Units.Meters),
ydir = new Vector(0, 1, 0, Units.Meters),
units = Units.Meters,
};
[Fact]
public void CanCreateArc_HalfCircle_CounterClockwise()
{
var counterClockwiseArc = new Arc()
{
plane = TestPlaneCounterClockwise,
startPoint = new Point(1, 0, 0, Units.Meters),
endPoint = new Point(-1, 0, 0, Units.Meters),
midPoint = new Point(0, 1, 0, Units.Meters),
units = Units.Meters,
};
Point.Distance(counterClockwiseArc.midPoint, new Point(0, 1, 0, Units.Meters)).Should().BeApproximately(0, 0.0001);
Point
.Distance(counterClockwiseArc.plane.origin, new Point(0, 0, 0, Units.Meters))
.Should()
.BeApproximately(0, 0.0001);
(counterClockwiseArc.measure - Math.PI).Should().BeApproximately(0, 0.0001);
counterClockwiseArc.radius.Should().BeApproximately(1, 0.0001);
counterClockwiseArc.length.Should().BeApproximately(Math.PI, 0.0001);
}
[Fact]
public void CanCreateArc_HalfCircle_Clockwise()
{
var clockwiseArc = new Arc()
{
plane = TestPlaneClockwise,
endPoint = new Point(1, 0, 0, Units.Meters),
startPoint = new Point(-1, 0, 0, Units.Meters),
midPoint = new Point(0, 1, 0, Units.Meters),
units = Units.Meters,
};
Point.Distance(clockwiseArc.midPoint, new Point(0, 1, 0, Units.Meters)).Should().BeApproximately(0, 0.0001);
Point.Distance(clockwiseArc.plane.origin, new Point(0, 0, 0, Units.Meters)).Should().BeApproximately(0, 0.0001);
(clockwiseArc.measure - Math.PI).Should().BeApproximately(0, 0.0001);
clockwiseArc.radius.Should().BeApproximately(1, 0.0001);
clockwiseArc.length.Should().BeApproximately(Math.PI, 0.0001);
}
}