-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revit fallback to Element Converter (#3512)
* add root converter with fallback and tests * proper references * Converters work * fmt * added test! * fmt
- Loading branch information
1 parent
8405135
commit 77829a5
Showing
22 changed files
with
887 additions
and
53 deletions.
There are no files selected for viewing
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
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
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
61 changes: 61 additions & 0 deletions
61
DUI3-DX/Converters/Revit/Speckle.Converters.Revit2023.Tests/XyzConversionToPointTests.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,61 @@ | ||
using FluentAssertions; | ||
using Moq; | ||
using NUnit.Framework; | ||
using Objects; | ||
using Speckle.Converters.Common; | ||
using Speckle.Converters.Common.Objects; | ||
using Speckle.Converters.RevitShared.Services; | ||
using Speckle.Converters.RevitShared.ToSpeckle; | ||
using Speckle.Revit.Interfaces; | ||
|
||
namespace Speckle.Converters.Revit2023.Tests; | ||
|
||
public class XyzConversionToPointTests | ||
{ | ||
private readonly MockRepository _repository = new(MockBehavior.Strict); | ||
|
||
private readonly Mock<IConversionContextStack<IRevitDocument, IRevitForgeTypeId>> _revitConversionContextStack; | ||
private readonly Mock<IScalingServiceToSpeckle> _scalingServiceToSpeckle; | ||
|
||
public XyzConversionToPointTests() | ||
{ | ||
_revitConversionContextStack = _repository.Create<IConversionContextStack<IRevitDocument, IRevitForgeTypeId>>(); | ||
_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<IRevitXYZ>(); | ||
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<IRevitDocument>>(); | ||
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); | ||
} | ||
} |
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
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
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
11 changes: 11 additions & 0 deletions
11
DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/RevitRootElementProvider.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,11 @@ | ||
using Speckle.Converters.Common; | ||
using Speckle.Revit.Interfaces; | ||
|
||
namespace Speckle.Converters.RevitShared; | ||
|
||
public class RevitRootElementProvider : IRootElementProvider | ||
{ | ||
private static readonly Type s_wrappedElementType = typeof(IRevitElement); | ||
|
||
public Type GetRootType() => s_wrappedElementType; | ||
} |
Oops, something went wrong.