Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 53888617f5 | |||
| 6a0b126e5b | |||
| a7d2e047b3 | |||
| 938bc803c6 | |||
| ecbb2244a1 | |||
| 0792192b27 | |||
| ef56b9c331 | |||
| eb65b91e43 | |||
| 782c87cda8 | |||
| 6bdd0a5bce |
+2
-2
@@ -83,9 +83,9 @@ Target(
|
||||
return Glob.Files(".", d);
|
||||
}
|
||||
|
||||
foreach (var file in GetFiles("**/*.Test.csproj"))
|
||||
foreach (var file in GetFiles("**/*.Tests.csproj"))
|
||||
{
|
||||
Run("dotnet", $"test {file} -c Release --no-restore --verbosity=normal");
|
||||
Run("dotnet", $"test {file} -c Release --no-build --verbosity=normal");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
<Project>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Bullseye" Version="5.0.0"/>
|
||||
<PackageVersion Include="Bullseye" Version="5.0.0" />
|
||||
<PackageVersion Include="Glob" Version="1.1.9" />
|
||||
<PackageVersion Include="SimpleExec" Version="12.0.0"/>
|
||||
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
<PackageVersion Include="SimpleExec" Version="12.0.0" />
|
||||
<PackageVersion Include="Speckle.ProxyGenerator" Version="0.1.6" />
|
||||
<PackageVersion Include="Mapster" Version="7.3.0" />
|
||||
<PackageVersion Include="MinVer" Version="5.0.0" />
|
||||
<PackageVersion Include="MinVer" Version="5.0.0" />
|
||||
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
|
||||
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
|
||||
<PackageVersion Include="Moq" Version="4.20.70" />
|
||||
<PackageVersion Include="NUnit" Version="4.1.0" />
|
||||
<PackageVersion Include="NUnit.Analyzers" Version="4.2.0" />
|
||||
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Autodesk.Revit.DB;
|
||||
using Mapster.Utils;
|
||||
using Speckle.ProxyGenerator;
|
||||
using Speckle.Revit.Interfaces;
|
||||
#pragma warning disable CA1010
|
||||
@@ -26,14 +25,16 @@ public partial interface IRevitForgeTypeIdProxy : IRevitForgeTypeId;
|
||||
[Proxy(
|
||||
typeof(Element),
|
||||
ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface,
|
||||
new[] { "Parameter", "BoundingBox", "Geometry" }
|
||||
new[] { "Parameter", "BoundingBox", "Geometry", "Location" }
|
||||
)]
|
||||
public partial interface IRevitElementProxy : IRevitElement;
|
||||
|
||||
public partial class ElementProxy
|
||||
{
|
||||
public IRevitParameter GetParameter(RevitBuiltInParameter builtInParameter) =>
|
||||
new ParameterProxy(_Instance.get_Parameter(Enum<BuiltInParameter>.Parse(builtInParameter.ToString())));
|
||||
new ParameterProxy(
|
||||
_Instance.get_Parameter(EnumUtility<RevitBuiltInParameter, BuiltInParameter>.Convert(builtInParameter))
|
||||
);
|
||||
|
||||
public IRevitBoundingBoxXYZ GetBoundingBox() => new BoundingBoxXYZProxy(_Instance.get_BoundingBox(null));
|
||||
|
||||
@@ -129,6 +130,56 @@ public partial class ElementProxy
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitLevel? ToLevel()
|
||||
{
|
||||
if (_Instance is Level m)
|
||||
{
|
||||
return new LevelProxy(m);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitLocationPoint? GetLocationAsLocationPoint()
|
||||
{
|
||||
if (_Instance.Location is LocationPoint l)
|
||||
{
|
||||
return new LocationPointProxy(l);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitLocationCurve? GetLocationAsLocationCurve()
|
||||
{
|
||||
if (_Instance.Location is LocationCurve l)
|
||||
{
|
||||
return new LocationCurveProxy(l);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//location can be 3 types and need to handle it?
|
||||
public IRevitLocation Location
|
||||
{
|
||||
get
|
||||
{
|
||||
IRevitLocation? location = GetLocationAsLocationPoint();
|
||||
if (location is not null)
|
||||
{
|
||||
return location;
|
||||
}
|
||||
location = GetLocationAsLocationCurve();
|
||||
if (location is not null)
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
return new LocationProxy(_Instance.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Proxy(typeof(FamilySymbol), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
|
||||
@@ -13,6 +13,54 @@ public partial interface IRevitCurveElementProxy : IRevitCurveElement;
|
||||
[Proxy(typeof(Curve), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
public partial interface IRevitCurveProxy : IRevitCurve;
|
||||
|
||||
public partial class CurveProxy
|
||||
{
|
||||
public IRevitLine? ToLine()
|
||||
{
|
||||
if (_Instance is Line m)
|
||||
{
|
||||
return new LineProxy(m);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitArc? ToArc()
|
||||
{
|
||||
if (_Instance is Arc m)
|
||||
{
|
||||
return new ArcProxy(m);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitEllipse? ToEllipse()
|
||||
{
|
||||
if (_Instance is Ellipse m)
|
||||
{
|
||||
return new EllipseProxy(m);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitNurbSpline? ToNurbSpline()
|
||||
{
|
||||
if (_Instance is NurbSpline m)
|
||||
{
|
||||
return new NurbSplineProxy(m);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitHermiteSpline? ToHermiteSpline()
|
||||
{
|
||||
if (_Instance is HermiteSpline m)
|
||||
{
|
||||
return new HermiteSplineProxy(m);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[Proxy(typeof(XYZ), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
public partial interface IRevitXYZProxy : IRevitXYZ;
|
||||
|
||||
@@ -26,27 +74,6 @@ public partial interface IRevitLocationCurveProxy : IRevitLocationCurve;
|
||||
[Proxy(typeof(Location), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
public partial interface IRevitLocationProxy : IRevitLocation;
|
||||
|
||||
public partial class LocationProxy
|
||||
{
|
||||
public IRevitLocationPoint? ToLocationPoint()
|
||||
{
|
||||
if (_Instance is LocationPoint point)
|
||||
{
|
||||
return new LocationPointProxy(point);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRevitLocationCurve? ToLocationCurve()
|
||||
{
|
||||
if (_Instance is LocationCurve point)
|
||||
{
|
||||
return new LocationCurveProxy(point);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[Proxy(
|
||||
typeof(LocationPoint),
|
||||
ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface
|
||||
|
||||
@@ -72,7 +72,7 @@ public partial interface IRevitParameterProxy : IRevitParameter;
|
||||
public partial class ParameterProxy
|
||||
{
|
||||
public bool IsReadOnly => _Instance.IsReadOnly;
|
||||
public IRevitStorageType StorageType => Enum<IRevitStorageType>.Parse(_Instance.StorageType.ToString());
|
||||
public IRevitStorageType StorageType => EnumUtility<StorageType, IRevitStorageType>.Convert(_Instance.StorageType);
|
||||
}
|
||||
|
||||
[Proxy(typeof(Definition), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
@@ -102,7 +102,7 @@ public partial interface IRevitInternalDefinitionProxy : IRevitInternalDefinitio
|
||||
public partial class InternalDefinitionProxy
|
||||
{
|
||||
public RevitBuiltInParameter BuiltInParameter =>
|
||||
Enum<RevitBuiltInParameter>.Parse(_Instance.BuiltInParameter.ToString());
|
||||
EnumUtility<BuiltInParameter, RevitBuiltInParameter>.Convert(_Instance.BuiltInParameter);
|
||||
}
|
||||
|
||||
[Proxy(typeof(PolyLine), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
@@ -191,19 +191,24 @@ public partial interface IRevitLevelProxy : IRevitLevel;
|
||||
[Proxy(
|
||||
typeof(FamilyInstance),
|
||||
ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface,
|
||||
new[] { "ToRoom", "FromRoom", "Space", "Room", "StructuralType" }
|
||||
new[] { "ToRoom", "FromRoom", "Space", "Room", "StructuralType", "Location" }
|
||||
)]
|
||||
public partial interface IRevitFamilyInstanceProxy : IRevitFamilyInstance;
|
||||
|
||||
public partial class FamilyInstanceProxy
|
||||
{
|
||||
public RevitStructuralType StructuralType => Enum<RevitStructuralType>.Parse(_Instance.StructuralType.ToString());
|
||||
public RevitStructuralType StructuralType =>
|
||||
EnumUtility<Autodesk.Revit.DB.Structure.StructuralType, RevitStructuralType>.Convert(_Instance.StructuralType);
|
||||
}
|
||||
|
||||
[Proxy(typeof(Solid), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
public partial interface IRevitSolidProxy : IRevitSolid;
|
||||
|
||||
[Proxy(typeof(Group), ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface)]
|
||||
[Proxy(
|
||||
typeof(Group),
|
||||
ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface,
|
||||
new[] { "Location" }
|
||||
)]
|
||||
public partial interface IRevitGroupProxy : IRevitGroup;
|
||||
|
||||
[Proxy(
|
||||
@@ -222,7 +227,8 @@ public partial interface IRevitOptionsProxy : IRevitOptions;
|
||||
|
||||
public partial class OptionsProxy
|
||||
{
|
||||
public RevitViewDetailLevel DetailLevel => Enum<RevitViewDetailLevel>.Parse(_Instance.DetailLevel.ToString());
|
||||
public RevitViewDetailLevel DetailLevel =>
|
||||
EnumUtility<ViewDetailLevel, RevitViewDetailLevel>.Convert(_Instance.DetailLevel);
|
||||
}
|
||||
|
||||
[Proxy(
|
||||
@@ -379,7 +385,7 @@ public partial interface IRevitTopographySurfaceProxy : IRevitTopographySurface;
|
||||
[Proxy(
|
||||
typeof(SpatialElement),
|
||||
ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface,
|
||||
new[] { "GetBoundarySegments" }
|
||||
new[] { "GetBoundarySegments", "Location" }
|
||||
)]
|
||||
public partial interface IRevitSpatialElementProxy : IRevitSpatialElement;
|
||||
|
||||
@@ -397,3 +403,10 @@ public partial class SpatialElementProxy
|
||||
private static IEnumerable<IRevitBoundarySegment> GetSegments(IList<BoundarySegment> segments) =>
|
||||
segments.Select(seg => new BoundarySegmentProxy(seg));
|
||||
}
|
||||
|
||||
[Proxy(
|
||||
typeof(Panel),
|
||||
ImplementationOptions.UseExtendedInterfaces | ImplementationOptions.ProxyForBaseInterface,
|
||||
new[] { "GetRefGridLines" }
|
||||
)]
|
||||
public partial interface IRevitPanelProxy : IRevitPanel;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.PointClouds;
|
||||
using Mapster.Utils;
|
||||
using Speckle.ProxyGenerator;
|
||||
using Speckle.Revit.Interfaces;
|
||||
|
||||
@@ -13,7 +12,7 @@ public class RevitFilterFactory : IRevitFilterFactory
|
||||
|
||||
public IRevitLogicalAndFilterFilter CreateLogicalAndFilter(params IRevitElementFilter[] filters) =>
|
||||
new LogicalAndFilterProxy(
|
||||
new LogicalAndFilter(filters.Cast<IRevitElementFilterProxy>().Select(x => x._Instance).ToList())
|
||||
new LogicalAndFilter(filters.Cast<ElementFilterProxy>().Select(x => x._Instance).ToList())
|
||||
);
|
||||
|
||||
public IRevitElementMulticategoryFilter CreateElementMulticategoryFilter(
|
||||
@@ -21,19 +20,28 @@ public class RevitFilterFactory : IRevitFilterFactory
|
||||
bool inverted
|
||||
) =>
|
||||
new ElementMulticategoryFilterProxy(
|
||||
new ElementMulticategoryFilter(categories.Select(x => (BuiltInCategory)x).ToArray(), inverted)
|
||||
instance: new ElementMulticategoryFilter(
|
||||
categories.Select(EnumUtility<RevitBuiltInCategory, BuiltInCategory>.Convert).ToArray(),
|
||||
inverted
|
||||
)
|
||||
);
|
||||
|
||||
public IRevitFilteredElementCollector CreateFilteredElementCollector(
|
||||
IRevitDocument document,
|
||||
params IRevitElementId[] elementIds
|
||||
) =>
|
||||
new FilteredElementCollectorProxy(
|
||||
new FilteredElementCollector(
|
||||
((IRevitDocumentProxy)document)._Instance,
|
||||
elementIds.Cast<IRevitElementIdProxy>().Select(x => x._Instance).ToList()
|
||||
)
|
||||
);
|
||||
)
|
||||
{
|
||||
if (elementIds.Any())
|
||||
{
|
||||
return new FilteredElementCollectorProxy(
|
||||
new FilteredElementCollector(
|
||||
((DocumentProxy)document)._Instance,
|
||||
elementIds.Cast<ElementIdProxy>().Select(x => x._Instance).ToList()
|
||||
)
|
||||
);
|
||||
}
|
||||
return new FilteredElementCollectorProxy(new FilteredElementCollector(((DocumentProxy)document)._Instance));
|
||||
}
|
||||
|
||||
public IRevitPointCloudFilter CreateMultiPlaneFilter(params IRevitPlane[] planes) =>
|
||||
new PointCloudFilterProxy(
|
||||
@@ -41,7 +49,9 @@ public class RevitFilterFactory : IRevitFilterFactory
|
||||
);
|
||||
|
||||
public IRevitElementCategoryFilter CreateElementCategoryFilter(RevitBuiltInCategory category) =>
|
||||
new ElementCategoryFilterProxy(new ElementCategoryFilter(Enum<BuiltInCategory>.Parse(category.ToString())));
|
||||
new ElementCategoryFilterProxy(
|
||||
new ElementCategoryFilter(EnumUtility<RevitBuiltInCategory, BuiltInCategory>.Convert(category))
|
||||
);
|
||||
}
|
||||
|
||||
[Proxy(
|
||||
@@ -88,5 +98,12 @@ public partial interface IRevitFilteredElementCollectorProxy : IRevitFilteredEle
|
||||
|
||||
public partial class FilteredElementCollectorProxy
|
||||
{
|
||||
public IEnumerable<T> OfClass<T>() => _Instance.OfClass(typeof(T)).Cast<T>();
|
||||
public IEnumerable<T> OfClass<T>(IProxyMap proxyMap) =>
|
||||
_Instance
|
||||
.OfClass(
|
||||
proxyMap.UnmapType(typeof(T))
|
||||
?? throw new InvalidOperationException($"Could not unmap type: {typeof(T).FullName}")
|
||||
)
|
||||
.Select(x => proxyMap.CreateProxy(typeof(T), x))
|
||||
.Cast<T>();
|
||||
}
|
||||
|
||||
@@ -91,5 +91,7 @@ public class RevitSolidUtils : IRevitSolidUtils
|
||||
public class RevitOptionsFactory : IRevitOptionsFactory
|
||||
{
|
||||
public IRevitOptions Create(RevitViewDetailLevel viewDetailLevel) =>
|
||||
new OptionsProxy(new Options() { DetailLevel = Enum<ViewDetailLevel>.Parse(viewDetailLevel.ToString()) });
|
||||
new OptionsProxy(
|
||||
new Options() { DetailLevel = EnumUtility<RevitViewDetailLevel, ViewDetailLevel>.Convert(viewDetailLevel) }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Speckle.Revit.Interfaces
|
||||
{
|
||||
public static class EnumUtility<TSource, TDestination>
|
||||
where TSource : struct, Enum
|
||||
where TDestination : struct, Enum
|
||||
{
|
||||
private static readonly ConcurrentDictionary<TSource, TDestination> _destinations = new();
|
||||
|
||||
static EnumUtility()
|
||||
{
|
||||
var sources = ((TSource[])Enum.GetValues(typeof(TSource))).Select(x => (x.ToString(), x));
|
||||
var destinations = Enum.GetNames(typeof(TDestination))
|
||||
.Select(x => (x, (TDestination)Enum.Parse(typeof(TDestination), x.ToString())))
|
||||
.ToList();
|
||||
foreach (var (name, val) in sources)
|
||||
{
|
||||
var d = destinations.Where(x => x.Item1 == name).ToList();
|
||||
if (d.Any())
|
||||
{
|
||||
foreach (var v in d)
|
||||
{
|
||||
destinations.Remove(v);
|
||||
}
|
||||
_destinations.TryAdd(val, d.Single().Item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TDestination Convert(TSource source)
|
||||
{
|
||||
if (_destinations.TryGetValue(source, out var destination))
|
||||
{
|
||||
return destination;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException($"{source} does not exist in destination enum: {typeof(TDestination)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,11 @@ public interface IRevitCurve : IRevitGeometryObject
|
||||
double GetEndParameter(int index);
|
||||
bool IsBound { get; }
|
||||
IList<IRevitXYZ> Tessellate();
|
||||
IRevitLine? ToLine();
|
||||
IRevitArc? ToArc();
|
||||
IRevitEllipse? ToEllipse();
|
||||
IRevitNurbSpline? ToNurbSpline();
|
||||
IRevitHermiteSpline? ToHermiteSpline();
|
||||
}
|
||||
|
||||
public interface IRevitCloudPoint
|
||||
|
||||
@@ -25,13 +25,17 @@ public interface IRevitElement : IRevitObject
|
||||
IRevitSketch? ToSketch();
|
||||
IRevitFloor? ToFloor();
|
||||
IRevitModelLine? ToModelLine();
|
||||
IRevitLevel? ToLevel();
|
||||
IRevitLocation Location { get; }
|
||||
|
||||
IRevitLocationPoint? GetLocationAsLocationPoint();
|
||||
IRevitLocationCurve? GetLocationAsLocationCurve();
|
||||
|
||||
IRevitParameterSet Parameters { get; }
|
||||
|
||||
IRevitParameter? GetParameter(RevitBuiltInParameter parameter);
|
||||
|
||||
IRevitGeometryElement GetGeometry(IRevitOptions options);
|
||||
IRevitLocation Location { get; }
|
||||
}
|
||||
|
||||
public interface IRevitParameterSet : IEnumerable<IRevitParameter>, IDisposable;
|
||||
|
||||
@@ -19,3 +19,25 @@ public interface IRevitFilterFactory
|
||||
IRevitPointCloudFilter CreateMultiPlaneFilter(params IRevitPlane[] planes);
|
||||
IRevitElementCategoryFilter CreateElementCategoryFilter(RevitBuiltInCategory category);
|
||||
}
|
||||
|
||||
public interface IProxyMap
|
||||
{
|
||||
Type? GetMappedType(Type type);
|
||||
Type? UnmapType(Type type);
|
||||
|
||||
object CreateProxy(Type type, object toWrap);
|
||||
}
|
||||
|
||||
// ghetto default interface implementation :(
|
||||
public static class ProxyMapExtensions
|
||||
{
|
||||
public static (Type, object)? WrapIfExists(this IProxyMap proxyMap, Type target, object toWrap)
|
||||
{
|
||||
var proxyType = proxyMap.GetMappedType(target);
|
||||
if (proxyType is not null)
|
||||
{
|
||||
return (proxyType, proxyMap.CreateProxy(proxyType, toWrap));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
public interface IRevitFilteredElementCollector : IRevitElementFilter
|
||||
{
|
||||
IEnumerable<T> OfClass<T>();
|
||||
IEnumerable<T> OfClass<T>(IProxyMap proxyMap);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
namespace Speckle.Revit.Interfaces;
|
||||
|
||||
public interface IRevitLocation : IRevitObject
|
||||
{
|
||||
IRevitLocationPoint? ToLocationPoint();
|
||||
|
||||
IRevitLocationCurve? ToLocationCurve();
|
||||
}
|
||||
public interface IRevitLocation : IRevitObject;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
namespace Speckle.Revit.Interfaces;
|
||||
|
||||
public interface IRevitObject;
|
||||
|
||||
public interface IRevitPanel : IRevitFamilyInstance;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -44,6 +44,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{42C36267
|
||||
.github\workflows\main.yml = .github\workflows\main.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Tests", "Speckle.Tests\Speckle.Tests.csproj", "{D909A986-7D4F-45A6-B0A2-D69D4CEF86C5}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{1A746BD2-E68A-4877-9922-3549F6C00EDF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -70,6 +74,10 @@ Global
|
||||
{00F3BEC6-614D-4AEE-923A-0E2DF40FDE6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{00F3BEC6-614D-4AEE-923A-0E2DF40FDE6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{00F3BEC6-614D-4AEE-923A-0E2DF40FDE6B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D909A986-7D4F-45A6-B0A2-D69D4CEF86C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D909A986-7D4F-45A6-B0A2-D69D4CEF86C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D909A986-7D4F-45A6-B0A2-D69D4CEF86C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D909A986-7D4F-45A6-B0A2-D69D4CEF86C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{CB5177F3-6FA5-4351-8BF1-3F6F2758096D} = {8F540B7F-7548-46E9-BDEC-4DAB99367908}
|
||||
@@ -81,5 +89,6 @@ Global
|
||||
{E5BCFB04-C8E2-4F34-8E12-E4E6CB908153} = {8B47C7AE-9C8C-47D5-A3C5-ACEFCF54E3B9}
|
||||
{917D7C89-FA2D-4A26-906B-E18317C49734} = {8B47C7AE-9C8C-47D5-A3C5-ACEFCF54E3B9}
|
||||
{00F3BEC6-614D-4AEE-923A-0E2DF40FDE6B} = {42C36267-88A8-4F94-9E62-5D43A02D033C}
|
||||
{D909A986-7D4F-45A6-B0A2-D69D4CEF86C5} = {1A746BD2-E68A-4877-9922-3549F6C00EDF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using Speckle.Revit.Interfaces;
|
||||
|
||||
namespace Speckle.Tests;
|
||||
|
||||
public class EnumUtilityTests
|
||||
{
|
||||
public enum Test1
|
||||
{
|
||||
X = 1,
|
||||
Y = 2,
|
||||
}
|
||||
|
||||
public enum Test2
|
||||
{
|
||||
X = 3,
|
||||
Y = 4
|
||||
}
|
||||
|
||||
public enum Test3
|
||||
{
|
||||
X = 3,
|
||||
XX = 4
|
||||
}
|
||||
|
||||
public enum Test4
|
||||
{
|
||||
X = 3,
|
||||
XX = 3,
|
||||
Y = 4
|
||||
}
|
||||
|
||||
public enum NonDefined1
|
||||
{
|
||||
Xstandard,
|
||||
Ystandard
|
||||
}
|
||||
|
||||
public enum NonDefined2
|
||||
{
|
||||
Xstandard,
|
||||
Ystandard
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Works_1_2()
|
||||
{
|
||||
var x = EnumUtility<Test1, Test2>.Convert(Test1.X);
|
||||
x.Should().Be(Test2.X);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Works_1_3()
|
||||
{
|
||||
var x = EnumUtility<Test1, Test3>.Convert(Test1.X);
|
||||
x.Should().Be(Test3.X);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Works_2_4()
|
||||
{
|
||||
var x = EnumUtility<Test2, Test4>.Convert(Test2.Y);
|
||||
x.Should().Be(Test4.Y);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Works_4_2()
|
||||
{
|
||||
var x = EnumUtility<Test4, Test2>.Convert(Test4.XX);
|
||||
x.Should().Be(Test2.X);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Works_D1_D2()
|
||||
{
|
||||
var x = EnumUtility<NonDefined1, NonDefined2>.Convert(NonDefined1.Xstandard);
|
||||
x.Should().Be(NonDefined2.Xstandard);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="NUnit"/>
|
||||
<PackageReference Include="NUnit.Analyzers" />
|
||||
<PackageReference Include="coverlet.collector" />
|
||||
<PackageReference Include="NUnit3TestAdapter" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Revit\Revit2023\Speckle.Revit2023.Interfaces\Speckle.Revit2023.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dependencies": {
|
||||
"net8.0": {
|
||||
"coverlet.collector": {
|
||||
"type": "Direct",
|
||||
"requested": "[6.0.2, )",
|
||||
"resolved": "6.0.2",
|
||||
"contentHash": "bJShQ6uWRTQ100ZeyiMqcFlhP7WJ+bCuabUs885dJiBEzMsJMSFr7BOyeCw4rgvQokteGi5rKQTlkhfQPUXg2A=="
|
||||
},
|
||||
"FluentAssertions": {
|
||||
"type": "Direct",
|
||||
"requested": "[6.12.0, )",
|
||||
"resolved": "6.12.0",
|
||||
"contentHash": "ZXhHT2YwP9lajrwSKbLlFqsmCCvFJMoRSK9t7sImfnCyd0OB3MhgxdoMcVqxbq1iyxD6mD2fiackWmBb7ayiXQ==",
|
||||
"dependencies": {
|
||||
"System.Configuration.ConfigurationManager": "4.4.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.NET.Test.Sdk": {
|
||||
"type": "Direct",
|
||||
"requested": "[17.10.0, )",
|
||||
"resolved": "17.10.0",
|
||||
"contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==",
|
||||
"dependencies": {
|
||||
"Microsoft.CodeCoverage": "17.10.0",
|
||||
"Microsoft.TestPlatform.TestHost": "17.10.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=="
|
||||
},
|
||||
"NUnit.Analyzers": {
|
||||
"type": "Direct",
|
||||
"requested": "[4.2.0, )",
|
||||
"resolved": "4.2.0",
|
||||
"contentHash": "4fJojPkzdoa4nB2+p6U+fITvPnVvwWSnsmiJ/Dl30xqiL3oxNbYvfeSLVd91hOmEjoUqSwN3Z7j1aFedjqWbUA=="
|
||||
},
|
||||
"NUnit3TestAdapter": {
|
||||
"type": "Direct",
|
||||
"requested": "[4.5.0, )",
|
||||
"resolved": "4.5.0",
|
||||
"contentHash": "s8JpqTe9bI2f49Pfr3dFRfoVSuFQyraTj68c3XXjIS/MRGvvkLnrg6RLqnTjdShX+AdFUCCU/4Xex58AdUfs6A=="
|
||||
},
|
||||
"Castle.Core": {
|
||||
"type": "Transitive",
|
||||
"resolved": "5.1.1",
|
||||
"contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==",
|
||||
"dependencies": {
|
||||
"System.Diagnostics.EventLog": "6.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.CodeCoverage": {
|
||||
"type": "Transitive",
|
||||
"resolved": "17.10.0",
|
||||
"contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA=="
|
||||
},
|
||||
"Microsoft.TestPlatform.ObjectModel": {
|
||||
"type": "Transitive",
|
||||
"resolved": "17.10.0",
|
||||
"contentHash": "KkwhjQevuDj0aBRoPLY6OLAhGqbPUEBuKLbaCs0kUVw29qiOYncdORd4mLVJbn9vGZ7/iFGQ/+AoJl0Tu5Umdg==",
|
||||
"dependencies": {
|
||||
"System.Reflection.Metadata": "1.6.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.TestPlatform.TestHost": {
|
||||
"type": "Transitive",
|
||||
"resolved": "17.10.0",
|
||||
"contentHash": "LWpMdfqhHvcUkeMCvNYJO8QlPLlYz9XPPb+ZbaXIKhdmjAV0wqTSrTiW5FLaf7RRZT50AQADDOYMOe0HxDxNgA==",
|
||||
"dependencies": {
|
||||
"Microsoft.TestPlatform.ObjectModel": "17.10.0",
|
||||
"Newtonsoft.Json": "13.0.1"
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json": {
|
||||
"type": "Transitive",
|
||||
"resolved": "13.0.1",
|
||||
"contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A=="
|
||||
},
|
||||
"System.Configuration.ConfigurationManager": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.4.0",
|
||||
"contentHash": "gWwQv/Ug1qWJmHCmN17nAbxJYmQBM/E94QxKLksvUiiKB1Ld3Sc/eK1lgmbSjDFxkQhVuayI/cGFZhpBSodLrg==",
|
||||
"dependencies": {
|
||||
"System.Security.Cryptography.ProtectedData": "4.4.0"
|
||||
}
|
||||
},
|
||||
"System.Diagnostics.EventLog": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
"contentHash": "lcyUiXTsETK2ALsZrX+nWuHSIQeazhqPphLfaRxzdGaG93+0kELqpgEHtwWOlQe7+jSFnKwaCAgL4kjeZCQJnw=="
|
||||
},
|
||||
"System.Reflection.Metadata": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.6.0",
|
||||
"contentHash": "COC1aiAJjCoA5GBF+QKL2uLqEBew4JsCkQmoHKbN3TlOZKa2fKLz5CpiRQKDz0RsAOEGsVKqOD5bomsXq/4STQ=="
|
||||
},
|
||||
"System.Security.Cryptography.ProtectedData": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.4.0",
|
||||
"contentHash": "cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog=="
|
||||
},
|
||||
"speckle.revit2023.interfaces": {
|
||||
"type": "Project"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user