Skip to content

Commit

Permalink
Add fakes nuget and another test
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Jul 1, 2024
1 parent e954244 commit 61a1512
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
</ItemGroup>

<ItemGroup>
<Reference Include="Speckle.Revit2023.Fakes">
<HintPath>..\..\..\..\..\speckle-sharp-host-apis\Speckle.Revit2023.Fakes\bin\Debug\net8.0\Speckle.Revit2023.Fakes.dll</HintPath>
</Reference>
<PackageReference Include="Speckle.Revit2023.Fakes" VersionOverride="0.2.1-preview.3" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
"resolved": "0.9.5",
"contentHash": "oU/L7pN1R7q8KkbrpQ3WJnHirPHqn+9DEA7asOcUiggV5dzVg1A/VYs7GOSusD24njxXh03tE3a2oTLOjt3cVg=="
},
"Speckle.Revit2023.Fakes": {
"type": "Direct",
"requested": "[0.2.1-preview.3, )",
"resolved": "0.2.1-preview.3",
"contentHash": "CFmjXwQCUBArsbaXXjEjtPHbu9kaGshYtJOyFl4zuJweTMC8taSEDpJVt7KSF6MB7xMO+y7AQ/GNLc5Rx4Hvqg=="
},
"Castle.Core": {
"type": "Transitive",
"resolved": "5.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace Speckle.Converters.RevitShared.ToSpeckle;

public class XyzConversionToPoint : ITypedConverter<DB.XYZ, SOG.Point>
{
private readonly ScalingServiceToSpeckle _toSpeckleScalingService;
private readonly IScalingServiceToSpeckle _toSpeckleScalingService;
private readonly IRevitConversionContextStack _contextStack;

public XyzConversionToPoint(
ScalingServiceToSpeckle toSpeckleScalingService,
IScalingServiceToSpeckle toSpeckleScalingService,
IRevitConversionContextStack contextStack
)
{
Expand Down
1 change: 1 addition & 0 deletions DUI3-DX/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PackageVersion Include="Speckle.Objects" Version="3.0.1-alpha.14" />
<PackageVersion Include="Speckle.AutoCAD.API" Version="2023.0.0" />
<PackageVersion Include="Speckle.Revit.API" Version="2023.0.0" />
<PackageVersion Include="Speckle.Revit2023.Fakes" Version="0.2.1-preview.2" />
<PackageVersion Include="RhinoCommon" Version="7.13.21348.13001" />
<PackageVersion Include="RhinoWindows" Version="7.13.21348.13001" />
<PackageVersion Include="System.Resources.Extensions" Version="7.0.0"/>
Expand Down

0 comments on commit 61a1512

Please sign in to comment.