Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Revit 2023 and Rhino 7 Converter Tests with Fakes #3549

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Civil3d", "Civil3d", "{34A6
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.Civil3dShared", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3dShared\Speckle.Converters.Civil3dShared.shproj", "{35175682-DA83-4C0A-A49D-B191F5885D8E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{99C39008-706C-45B9-8E7E-9D9B8928A278}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Rhino7.Tests", "DUI3-DX\Converters\Rhino\Speckle.Converters.Rhino7.Tests\Speckle.Converters.Rhino7.Tests.csproj", "{DB892409-2185-4DDE-983E-F0DE4766129A}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Speckle.Converters.RhinoShared", "DUI3-DX\Converters\Rhino\Speckle.Converters.RhinoShared\Speckle.Converters.RhinoShared.shproj", "{E1C43415-3200-45F4-8BF9-A4DD7D7F2ED9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Civil3d2024", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3d2024\Speckle.Converters.Civil3d2024.csproj", "{E7FA6A25-A224-4207-846B-75CE8236228D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speckle.Converters.Civil3d2024.DependencyInjection", "DUI3-DX\Converters\Civil3d\Speckle.Converters.Civil3d2024.DependencyInjection\Speckle.Converters.Civil3d2024.DependencyInjection.csproj", "{9BCE88BA-1E01-44EE-BF9D-2CB906E63E34}"
Expand Down Expand Up @@ -2788,6 +2794,70 @@ Global
{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|Any CPU.Build.0 = Release|Any CPU
{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|x64.ActiveCfg = Release|Any CPU
{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E}.Release|x64.Build.0 = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug Mac|x64.Build.0 = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|x64.ActiveCfg = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Debug|x64.Build.0 = Debug|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|x64.ActiveCfg = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release Mac|x64.Build.0 = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|Any CPU.Build.0 = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.ActiveCfg = Release|Any CPU
{C9C28F31-1367-438C-83B0-049C3B3A3E3B}.Release|x64.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug Mac|x64.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.ActiveCfg = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Debug|x64.Build.0 = Debug|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release Mac|x64.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|Any CPU.Build.0 = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.ActiveCfg = Release|Any CPU
{06082BAA-98E8-49B1-9D33-252B126A0561}.Release|x64.Build.0 = Release|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug Mac|x64.Build.0 = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug|x64.ActiveCfg = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Debug|x64.Build.0 = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release Mac|Any CPU.Build.0 = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release Mac|x64.ActiveCfg = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release Mac|x64.Build.0 = Debug|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release|Any CPU.Build.0 = Release|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release|x64.ActiveCfg = Release|Any CPU
{99C39008-706C-45B9-8E7E-9D9B8928A278}.Release|x64.Build.0 = Release|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug Mac|x64.Build.0 = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug|x64.ActiveCfg = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Debug|x64.Build.0 = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release Mac|Any CPU.Build.0 = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release Mac|x64.ActiveCfg = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release Mac|x64.Build.0 = Debug|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release|Any CPU.Build.0 = Release|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release|x64.ActiveCfg = Release|Any CPU
{DB892409-2185-4DDE-983E-F0DE4766129A}.Release|x64.Build.0 = Release|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{E7FA6A25-A224-4207-846B-75CE8236228D}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -3094,6 +3164,13 @@ Global
{70DEAA13-6DC8-44A0-B287-9E806A8054F1} = {890F3257-FCC2-4ED8-9180-22B3641B494C}
{F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934}
{DDBBA313-69A6-40DE-AB3A-79EE5BF32A7E} = {743489BF-1941-43D5-8AF9-35C56D0DCC34}
{631C295A-7CCF-4B42-8686-7034E31469E7} = {804E065F-914C-414A-AF84-009312C3CFF6}
{D940853C-003A-482C-BDB0-665367F274A0} = {804E065F-914C-414A-AF84-009312C3CFF6}
{C9C28F31-1367-438C-83B0-049C3B3A3E3B} = {804E065F-914C-414A-AF84-009312C3CFF6}
{06082BAA-98E8-49B1-9D33-252B126A0561} = {804E065F-914C-414A-AF84-009312C3CFF6}
{99C39008-706C-45B9-8E7E-9D9B8928A278} = {D92751C8-1039-4005-90B2-913E55E0B8BD}
{DB892409-2185-4DDE-983E-F0DE4766129A} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3}
{E1C43415-3200-45F4-8BF9-A4DD7D7F2ED9} = {34C2C062-E43F-4FB5-B839-64BC044CCEF3}
{34A6BB15-A030-4C5B-94B2-1A1DFE49334A} = {1FE3C60E-7865-40A5-9794-55ECB64F6489}
{35175682-DA83-4C0A-A49D-B191F5885D8E} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A}
{E7FA6A25-A224-4207-846B-75CE8236228D} = {34A6BB15-A030-4C5B-94B2-1A1DFE49334A}
Expand Down
3 changes: 3 additions & 0 deletions DUI3-DX.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
"DUI3-DX\\Converters\\Civil3d\\Speckle.Converters.Civil3d2024\\Speckle.Converters.Civil3d2024.csproj",
"DUI3-DX\\Converters\\Civil3d\\Speckle.Converters.Civil3dShared\\Speckle.Converters.Civil3dShared.shproj",
"DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.DependencyInjection\\Speckle.Converters.Revit2023.DependencyInjection.csproj",
"DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023.Tests\\Speckle.Converters.Revit2023.Tests.csproj",
"DUI3-DX\\Converters\\Revit\\Speckle.Converters.Revit2023\\Speckle.Converters.Revit2023.csproj",
"DUI3-DX\\Converters\\Revit\\Speckle.Converters.RevitShared\\Speckle.Converters.RevitShared.shproj",
"DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.DependencyInjection\\Speckle.Converters.Rhino7.DependencyInjection.csproj",
"DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7.Tests\\Speckle.Converters.Rhino7.Tests.csproj",
"DUI3-DX\\Converters\\Rhino\\Speckle.Converters.Rhino7\\Speckle.Converters.Rhino7.csproj",
"DUI3-DX\\Converters\\Rhino\\Speckle.Converters.RhinoShared\\Speckle.Converters.RhinoShared.shproj",
"DUI3-DX\\DUI3\\Speckle.Connectors.DUI.WebView\\Speckle.Connectors.DUI.WebView.csproj",
"DUI3-DX\\DUI3\\Speckle.Connectors.DUI\\Speckle.Connectors.DUI.csproj",
"DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,17 @@
"Speckle.Converters.Common": "[2.0.999-local, )"
}
},
"speckle.converters.rhino7": {
"type": "Project",
"dependencies": {
"RhinoCommon": "[7.13.21348.13001, )",
"Speckle.Converters.Common": "[2.0.999-local, )"
}
},
"speckle.converters.rhino7.dependencyinjection": {
"type": "Project",
"dependencies": {
"RhinoCommon": "[7.13.21348.13001, )"
"Speckle.Converters.Rhino7": "[2.0.999-local, )"
}
},
"Microsoft.Extensions.Logging.Abstractions": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System.Collections;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using Objects;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
using Speckle.Converters.RevitShared;
using Speckle.Converters.RevitShared.Helpers;
using Speckle.Converters.RevitShared.Raw;
using Speckle.Converters.RevitShared.Services;

namespace Speckle.Converters.Revit2023.Tests;

public class ModelCurveArrayToSpeckleConverterTests
{
private MockRepository _repository;

private Mock<IRevitConversionContextStack> _revitConversionContextStack;
private Mock<IScalingServiceToSpeckle> _scalingServiceToSpeckle;
private Mock<ITypedConverter<DB.Curve, ICurve>> _curveConverter;

[SetUp]
public void Start()
{
_repository = new(MockBehavior.Strict);
_revitConversionContextStack = _repository.Create<IRevitConversionContextStack>();
_scalingServiceToSpeckle = _repository.Create<IScalingServiceToSpeckle>();
_curveConverter = _repository.Create<ITypedConverter<DB.Curve, ICurve>>();
}

[TearDown]
public void Verify() => _repository.VerifyAll();

[Test]
public void Convert_Empty()
{
var sut = new ModelCurveArrayToSpeckleConverter(
_revitConversionContextStack.Object,
_scalingServiceToSpeckle.Object,
_curveConverter.Object
);
var array = _repository.Create<DB.ModelCurveArray>();
array.Setup(x => x.GetEnumerator()).Returns(Enumerable.Empty<object>().GetEnumerator());
Assert.Throws<SpeckleConversionException>(() => sut.Convert(array.Object));
}

[Test]
public void Convert()
{
var endpoint1 = _repository.Create<DB.XYZ>();
var geometry1 = _repository.Create<DB.Curve>();
var curve1 = _repository.Create<DB.ModelCurve>();
curve1.Setup(x => x.GeometryCurve).Returns(geometry1.Object);
geometry1.Setup(x => x.Length).Returns(2);
geometry1.Setup(x => x.GetEndPoint(0)).Returns(endpoint1.Object);

var endpoint2 = _repository.Create<DB.XYZ>();
var geometry2 = _repository.Create<DB.Curve>();
var curve2 = _repository.Create<DB.ModelCurve>();
curve2.Setup(x => x.GeometryCurve).Returns(geometry2.Object);
geometry2.Setup(x => x.Length).Returns(3);
geometry2.Setup(x => x.GetEndPoint(1)).Returns(endpoint2.Object);

var context = _repository.Create<IConversionContext<DB.Document>>();
_revitConversionContextStack.Setup(x => x.Current).Returns(context.Object);

var units = "units";
context.Setup(x => x.SpeckleUnits).Returns(units);

var scaleLength = 2.2;
_scalingServiceToSpeckle.Setup(x => x.ScaleLength(2 + 3)).Returns(scaleLength);

endpoint1.Setup(x => x.DistanceTo(endpoint2.Object)).Returns(4.4);

_curveConverter.Setup(x => x.Convert(geometry1.Object)).Returns(_repository.Create<ICurve>().Object);
_curveConverter.Setup(x => x.Convert(geometry2.Object)).Returns(_repository.Create<ICurve>().Object);

var sut = new ModelCurveArrayToSpeckleConverter(
_revitConversionContextStack.Object,
_scalingServiceToSpeckle.Object,
_curveConverter.Object
);
var array = _repository.Create<DB.ModelCurveArray>();

array
.Setup(x => x.GetEnumerator())
.Returns(new List<DB.ModelCurve> { curve1.Object, curve2.Object }.GetEnumerator());
var polycurve = sut.Convert(array.Object);

polycurve.units.Should().Be(units);
polycurve.closed.Should().BeFalse();
polycurve.length.Should().Be(scaleLength);
polycurve.segments.Count.Should().Be(2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit.Analyzers" />
</ItemGroup>
<Import Project="..\Speckle.Converters.RevitShared\Speckle.Converters.RevitShared.projitems" Label="Shared" />

<ItemGroup>
<ProjectReference Include="..\..\..\Sdk\Speckle.Converters.Common\Speckle.Converters.Common.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Speckle.Revit2023.Fakes" VersionOverride="[0.2.1-preview.6, 1.0.0)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using Speckle.Converters.Common;
using Speckle.Converters.RevitShared.Helpers;
using Speckle.Converters.RevitShared.Services;
using Speckle.Converters.RevitShared.ToSpeckle;

namespace Speckle.Converters.Revit2023.Tests;

public class XyzConversionToPointTests
{
private MockRepository _repository;

private Mock<IRevitConversionContextStack> _revitConversionContextStack;
private Mock<IScalingServiceToSpeckle> _scalingServiceToSpeckle;

[SetUp]
public void Setup()
{
_repository = new(MockBehavior.Strict);
_revitConversionContextStack = _repository.Create<IRevitConversionContextStack>();
_scalingServiceToSpeckle = _repository.Create<IScalingServiceToSpeckle>();
}

[TearDown]
public void Verify() => _repository.VerifyAll();

[Test]
public void Convert_Point()
{
var x = 3.1;
var y = 3.2;
var z = 3.3;
var xScaled = 4.1;
var yScaled = 4.2;
var zScaled = 4.3;
var xyz = _repository.Create<DB.XYZ>();
xyz.Setup(x => x.X).Returns(x);
xyz.Setup(x => x.Y).Returns(y);
xyz.Setup(x => x.Z).Returns(z);

var units = "units";
var conversionContext = _repository.Create<IConversionContext<DB.Document>>();
conversionContext.Setup(x => x.SpeckleUnits).Returns(units);

_scalingServiceToSpeckle.Setup(a => a.ScaleLength(x)).Returns(xScaled);
_scalingServiceToSpeckle.Setup(a => a.ScaleLength(y)).Returns(yScaled);
_scalingServiceToSpeckle.Setup(a => a.ScaleLength(z)).Returns(zScaled);

_revitConversionContextStack.Setup(x => x.Current).Returns(conversionContext.Object);

var converter = new XyzConversionToPoint(_scalingServiceToSpeckle.Object, _revitConversionContextStack.Object);
var point = converter.Convert(xyz.Object);

point.x.Should().Be(xScaled);
point.y.Should().Be(yScaled);
point.z.Should().Be(zScaled);
point.units.Should().Be(units);
}
}
Loading
Loading