-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
91a69a8
commit 23942b0
Showing
10 changed files
with
220 additions
and
66 deletions.
There are no files selected for viewing
72 changes: 30 additions & 42 deletions
72
...erters/Revit/Speckle.Converters.Revit2023.Tests/ModelCurveArrayToSpeckleConverterTests.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
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
65 changes: 65 additions & 0 deletions
65
Converters/Rhino/Speckle.Converters.Rhino7.Tests/ArcToSpeckleConverterTests.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,65 @@ | ||
using FluentAssertions; | ||
using Moq; | ||
using NUnit.Framework; | ||
using Rhino; | ||
using Speckle.Converters.Common; | ||
using Speckle.Converters.Common.Objects; | ||
using Speckle.Converters.Rhino7.ToSpeckle.Raw; | ||
using Speckle.Testing; | ||
|
||
namespace Speckle.Converters.Rhino7.Tests; | ||
|
||
public class ArcToSpeckleConverterTests : MoqTest | ||
{ | ||
[Test] | ||
public void Convert_ShouldConvertArcCorrectly() | ||
{ | ||
// Arrange | ||
var radius = 1.1d; | ||
var mockPointConverter = Create<ITypedConverter<RG.Point3d, SOG.Point>>(); | ||
var mockPlaneConverter = Create<ITypedConverter<RG.Plane, SOG.Plane>>(); | ||
var mockBoxConverter = Create<ITypedConverter<RG.Box, SOG.Box>>(); | ||
var mockContextStack = Create<IConversionContextStack<RhinoDoc, UnitSystem>>(); | ||
var factory = Create<IBoxFactory>(); | ||
|
||
var context = Create<IConversionContext<RhinoDoc>>(); | ||
context.Setup(x => x.SpeckleUnits).Returns("units"); | ||
mockContextStack.Setup(cs => cs.Current).Returns(context.Object); | ||
|
||
var targetArc = Create<RG.Arc>(); | ||
var targetPlane = Create<RG.Plane>(); | ||
var targetBox = Create<RG.Box>(); | ||
var point3d = Create<RG.Point3d>(); | ||
var boundbox = Create<RG.BoundingBox>(); | ||
|
||
targetArc.Setup(x => x.Plane).Returns(targetPlane.Object); | ||
targetArc.Setup(x => x.Radius).Returns(radius); | ||
targetArc.Setup(x => x.StartAngle).Returns(radius); | ||
targetArc.Setup(x => x.EndAngle).Returns(radius); | ||
targetArc.Setup(x => x.Angle).Returns(radius); | ||
targetArc.Setup(x => x.Length).Returns(radius); | ||
targetArc.Setup(x => x.StartPoint).Returns(point3d.Object); | ||
targetArc.Setup(x => x.MidPoint).Returns(point3d.Object); | ||
targetArc.Setup(x => x.EndPoint).Returns(point3d.Object); | ||
targetArc.Setup(x => x.BoundingBox()).Returns(boundbox.Object); | ||
factory.Setup(x => x.Create(boundbox.Object)).Returns(targetBox.Object); | ||
|
||
mockPlaneConverter.Setup(pc => pc.Convert(targetPlane.Object)).Returns(new SOG.Plane()); | ||
mockPointConverter.Setup(pc => pc.Convert(It.IsAny<RG.Point3d>())).Returns(new SOG.Point()); | ||
mockBoxConverter.Setup(bc => bc.Convert(targetBox.Object)).Returns(new SOG.Box()); | ||
|
||
var converter = new ArcToSpeckleConverter( | ||
mockPointConverter.Object, | ||
mockPlaneConverter.Object, | ||
mockBoxConverter.Object, | ||
mockContextStack.Object, | ||
factory.Object | ||
); | ||
|
||
// Act | ||
var result = converter.Convert(targetArc.Object); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
} | ||
} |
30 changes: 11 additions & 19 deletions
30
Converters/Rhino/Speckle.Converters.Rhino7.Tests/EllipseToSpeckleConverterTests.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 |
---|---|---|
@@ -1,29 +1,21 @@ | ||
using Moq; | ||
using NUnit.Framework; | ||
using NUnit.Framework; | ||
using Rhino; | ||
using Speckle.Converters.Common; | ||
using Speckle.Converters.Common.Objects; | ||
using Speckle.Converters.Rhino7.ToSpeckle.Raw; | ||
using Speckle.Testing; | ||
|
||
namespace Speckle.Converters.Rhino7.Tests; | ||
|
||
public class EllipseToSpeckleConverterTests | ||
public class EllipseToSpeckleConverterTests : MoqTest | ||
{ | ||
private MockRepository _repository; | ||
|
||
private Mock<IConversionContextStack<RhinoDoc, UnitSystem>> _conversionContextStack; | ||
|
||
private Mock<ITypedConverter<RG.Plane, SOG.Plane>> _planeConverter; | ||
private Mock<ITypedConverter<RG.Box, SOG.Box>> _boxConverter; | ||
|
||
[SetUp] | ||
public void Setup() | ||
[Test] | ||
public void Convert_Test() | ||
{ | ||
_repository = new(MockBehavior.Strict); | ||
_conversionContextStack = _repository.Create<IConversionContextStack<RhinoDoc, UnitSystem>>(); | ||
_planeConverter = _repository.Create<ITypedConverter<RG.Plane, SOG.Plane>>(); | ||
_boxConverter = _repository.Create<ITypedConverter<RG.Box, SOG.Box>>(); | ||
} | ||
var conversionContextStack = Create<IConversionContextStack<RhinoDoc, UnitSystem>>(); | ||
var planeConverter = Create<ITypedConverter<RG.Plane, SOG.Plane>>(); | ||
var boxConverter = Create<ITypedConverter<RG.Box, SOG.Box>>(); | ||
|
||
[TearDown] | ||
public void Verify() => _repository.VerifyAll(); | ||
var x = new EllipseToSpeckleConverter(planeConverter.Object, boxConverter.Object, conversionContextStack.Object); | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
Converters/Rhino/Speckle.Converters.RhinoShared/ToSpeckle/Raw/BoxFactory.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,9 @@ | ||
using Speckle.InterfaceGenerator; | ||
|
||
namespace Speckle.Converters.Rhino7.ToSpeckle.Raw; | ||
|
||
[GenerateAutoInterface] | ||
public class BoxFactory : IBoxFactory | ||
{ | ||
public RG.Box Create(RG.BoundingBox bb) => new(bb); | ||
} |
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,18 @@ | ||
using Moq; | ||
using NUnit.Framework; | ||
|
||
namespace Speckle.Testing; | ||
|
||
public abstract class MoqTest | ||
{ | ||
[SetUp] | ||
public void Setup() => Repository = new(MockBehavior.Strict); | ||
|
||
[TearDown] | ||
public void Verify() => Repository.VerifyAll(); | ||
|
||
protected MockRepository Repository { get; private set; } = new(MockBehavior.Strict); | ||
|
||
protected Mock<T> Create<T>() | ||
where T : class => Repository.Create<T>(); | ||
} |
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,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Moq" /> | ||
<PackageReference Include="NUnit" /> | ||
</ItemGroup> | ||
</Project> |
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,67 @@ | ||
{ | ||
"version": 2, | ||
"dependencies": { | ||
"net8.0": { | ||
"Microsoft.SourceLink.GitHub": { | ||
"type": "Direct", | ||
"requested": "[8.0.0, )", | ||
"resolved": "8.0.0", | ||
"contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==", | ||
"dependencies": { | ||
"Microsoft.Build.Tasks.Git": "8.0.0", | ||
"Microsoft.SourceLink.Common": "8.0.0" | ||
} | ||
}, | ||
"Moq": { | ||
"type": "Direct", | ||
"requested": "[4.20.70, )", | ||
"resolved": "4.20.70", | ||
"contentHash": "4rNnAwdpXJBuxqrOCzCyICXHSImOTRktCgCWXWykuF1qwoIsVvEnR7PjbMk/eLOxWvhmj5Kwt+kDV3RGUYcNwg==", | ||
"dependencies": { | ||
"Castle.Core": "5.1.1" | ||
} | ||
}, | ||
"NUnit": { | ||
"type": "Direct", | ||
"requested": "[4.1.0, )", | ||
"resolved": "4.1.0", | ||
"contentHash": "MT/DpAhjtiytzhTgTqIhBuWx4y26PKfDepYUHUM+5uv4TsryHC2jwFo5e6NhWkApCm/G6kZ80dRjdJFuAxq3rg==" | ||
}, | ||
"PolySharp": { | ||
"type": "Direct", | ||
"requested": "[1.14.1, )", | ||
"resolved": "1.14.1", | ||
"contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ==" | ||
}, | ||
"Speckle.InterfaceGenerator": { | ||
"type": "Direct", | ||
"requested": "[0.9.5, )", | ||
"resolved": "0.9.5", | ||
"contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg==" | ||
}, | ||
"Castle.Core": { | ||
"type": "Transitive", | ||
"resolved": "5.1.1", | ||
"contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==", | ||
"dependencies": { | ||
"System.Diagnostics.EventLog": "6.0.0" | ||
} | ||
}, | ||
"Microsoft.Build.Tasks.Git": { | ||
"type": "Transitive", | ||
"resolved": "8.0.0", | ||
"contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ==" | ||
}, | ||
"Microsoft.SourceLink.Common": { | ||
"type": "Transitive", | ||
"resolved": "8.0.0", | ||
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw==" | ||
}, | ||
"System.Diagnostics.EventLog": { | ||
"type": "Transitive", | ||
"resolved": "6.0.0", | ||
"contentHash": "lcyUiXTsETK2ALsZrX+nWuHSIQeazhqPphLfaRxzdGaG93+0kELqpgEHtwWOlQe7+jSFnKwaCAgL4kjeZCQJnw==" | ||
} | ||
} | ||
} | ||
} |