Skip to content

Commit 21ec0fd

Browse files
committed
update unit tests to Revit2025 & net8.0
1 parent e3a0364 commit 21ec0fd

File tree

8 files changed

+36
-203
lines changed

8 files changed

+36
-203
lines changed

.runsettings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<RunSettings>
22
<MSTest>
33
<AssemblyResolution>
4-
<Directory path="D:\Autodesk\Revit 2023\" includeSubDirectories="false"/>
4+
<Directory path="D:\Autodesk\Revit Preview\Revit Preview Release\" includeSubDirectories="false"/>
55
</AssemblyResolution>
66
</MSTest>
77
</RunSettings>

RevitTestLibrary.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.4.33205.214
@@ -8,7 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
88
README.md = README.md
99
EndProjectSection
1010
EndProject
11-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitTestLibrary.Demo.MSTestV3", "sources\RevitTestLibrary.Demo.MSTestV3\RevitTestLibrary.Demo.MSTestV3.csproj", "{801B8398-55BD-427A-859C-8537FFC49CBE}"
11+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitTestLibrary.Demo.MSTestV3", "sources\RevitTestLibrary.Demo.MSTestV3\RevitTestLibrary.Demo.MSTestV3.csproj", "{801B8398-55BD-427A-859C-8537FFC49CBE}"
1212
EndProject
1313
Global
1414
GlobalSection(SolutionConfigurationPlatforms) = preSolution

sources/RevitTestLibrary.Demo.MSTestV3/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 18 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,28 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.props" Condition="Exists('..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.props')" />
4-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
52
<PropertyGroup>
6-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8-
<ProjectGuid>{801B8398-55BD-427A-859C-8537FFC49CBE}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>RevitTestLibrary.Demo.MSTestV3</RootNamespace>
12-
<AssemblyName>RevitTestLibrary.Demo.MSTestV3</AssemblyName>
13-
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
16-
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
17-
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
18-
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
19-
<IsCodedUITest>False</IsCodedUITest>
20-
<TestProjectType>UnitTest</TestProjectType>
21-
<NuGetPackageImportStamp>
22-
</NuGetPackageImportStamp>
23-
</PropertyGroup>
24-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25-
<DebugSymbols>true</DebugSymbols>
26-
<DebugType>full</DebugType>
27-
<Optimize>false</Optimize>
28-
<OutputPath>bin\Debug\</OutputPath>
29-
<DefineConstants>DEBUG;TRACE</DefineConstants>
30-
<ErrorReport>prompt</ErrorReport>
31-
<WarningLevel>4</WarningLevel>
32-
</PropertyGroup>
33-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
34-
<DebugType>pdbonly</DebugType>
35-
<Optimize>true</Optimize>
36-
<OutputPath>bin\Release\</OutputPath>
37-
<DefineConstants>TRACE</DefineConstants>
38-
<ErrorReport>prompt</ErrorReport>
39-
<WarningLevel>4</WarningLevel>
3+
<TargetFramework>net8.0-windows</TargetFramework>
4+
<IsTestProject>true</IsTestProject>
5+
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
6+
<RunSettingsFilePath>$(MSBuildProjectDirectory)\..\..\.runsettings</RunSettingsFilePath>
407
</PropertyGroup>
418
<ItemGroup>
42-
<Reference Include="envdte80, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
43-
<HintPath>..\..\packages\envdte80.17.4.33103.184\lib\net472\envdte80.dll</HintPath>
44-
</Reference>
45-
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
46-
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
47-
</Reference>
48-
<Reference Include="Microsoft.VisualStudio.Interop, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
49-
<HintPath>..\..\packages\Microsoft.VisualStudio.Interop.17.4.33103.184\lib\net472\Microsoft.VisualStudio.Interop.dll</HintPath>
50-
</Reference>
51-
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
52-
<HintPath>..\..\packages\MSTest.TestFramework.3.0.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
53-
</Reference>
54-
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
55-
<HintPath>..\..\packages\MSTest.TestFramework.3.0.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
56-
</Reference>
57-
<Reference Include="netstandard" />
58-
<Reference Include="RevitAddInUtility, Version=23.0.0.0, Culture=neutral, processorArchitecture=MSIL">
59-
<HintPath>..\..\packages\RevitTestLibrary.0.0.5\lib\net48\RevitAddInUtility.dll</HintPath>
60-
</Reference>
9+
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
11+
12+
<PackageReference Include="MSTest.TestAdapter" Version="3.3.0-preview.24164.4" />
13+
<PackageReference Include="MSTest.TestFramework" Version="3.3.0-preview.24164.4" />
14+
15+
<PackageReference Include="RevitTestLibrary.MSTest" Version="0.1.2.2025" />
16+
17+
</ItemGroup>
18+
<ItemGroup>
6119
<Reference Include="RevitAPI">
62-
<HintPath>..\..\binaries\revit\2023\RevitAPI.dll</HintPath>
20+
<HintPath>D:\Autodesk\Revit Preview\Revit Preview Release\RevitAPI.dll</HintPath>
6321
<Private>False</Private>
6422
</Reference>
6523
<Reference Include="RevitAPIUI">
66-
<HintPath>..\..\binaries\revit\2023\RevitAPIUI.dll</HintPath>
24+
<HintPath>D:\Autodesk\Revit Preview\Revit Preview Release\RevitAPIUI.dll</HintPath>
6725
<Private>False</Private>
68-
</Reference>
69-
<Reference Include="RevitTestLibrary, Version=0.0.5.0, Culture=neutral, processorArchitecture=MSIL">
70-
<HintPath>..\..\packages\RevitTestLibrary.0.0.5\lib\net48\RevitTestLibrary.dll</HintPath>
71-
</Reference>
72-
<Reference Include="RevitTestLibrary.MSTest, Version=0.0.5.0, Culture=neutral, processorArchitecture=MSIL">
73-
<HintPath>..\..\packages\RevitTestLibrary.MSTest.0.0.5\lib\net48\RevitTestLibrary.MSTest.dll</HintPath>
74-
</Reference>
75-
<Reference Include="ServiceWire, Version=5.5.3.0, Culture=neutral, processorArchitecture=MSIL">
76-
<HintPath>..\..\packages\ServiceWire.5.5.3\lib\netstandard2.0\ServiceWire.dll</HintPath>
77-
</Reference>
78-
<Reference Include="System" />
79-
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
80-
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
81-
</Reference>
82-
<Reference Include="System.Core" />
83-
<Reference Include="System.IO.Pipes, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
84-
<HintPath>..\..\packages\System.IO.Pipes.4.3.0\lib\net46\System.IO.Pipes.dll</HintPath>
85-
<Private>True</Private>
86-
<Private>True</Private>
87-
</Reference>
88-
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
89-
<HintPath>..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
90-
</Reference>
91-
<Reference Include="System.Numerics" />
92-
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
93-
<HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
94-
</Reference>
95-
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
96-
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
97-
</Reference>
98-
<Reference Include="System.Text.Encodings.Web, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
99-
<HintPath>..\..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
100-
</Reference>
101-
<Reference Include="System.Text.Json, Version=6.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
102-
<HintPath>..\..\packages\System.Text.Json.6.0.4\lib\net461\System.Text.Json.dll</HintPath>
103-
</Reference>
104-
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
105-
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
106-
</Reference>
107-
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
108-
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
109-
</Reference>
110-
</ItemGroup>
111-
<ItemGroup>
112-
<Compile Include="UnitTest1.cs" />
113-
<Compile Include="Properties\AssemblyInfo.cs" />
114-
</ItemGroup>
115-
<ItemGroup>
116-
<None Include="app.config" />
117-
<None Include="packages.config" />
26+
</Reference>
11827
</ItemGroup>
119-
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
120-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
121-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
122-
<PropertyGroup>
123-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
124-
</PropertyGroup>
125-
<Error Condition="!Exists('..\..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets'))" />
126-
<Error Condition="!Exists('..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.props'))" />
127-
<Error Condition="!Exists('..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.targets'))" />
128-
</Target>
129-
<Import Project="..\..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets" Condition="Exists('..\..\packages\System.Text.Json.6.0.4\build\System.Text.Json.targets')" />
130-
<Import Project="..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.targets" Condition="Exists('..\..\packages\MSTest.TestAdapter.3.0.2\build\net462\MSTest.TestAdapter.targets')" />
13128
</Project>
Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
22
using System.IO;
3-
using System.Reflection;
43
using Autodesk.Revit.DB;
5-
using Autodesk.Revit.UI;
64
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using RevitTestLibrary.MSTest;
5+
using RevitTestLibrary;
6+
7+
8+
[assembly: RevitPath("D:\\Autodesk\\Revit Preview\\Revit Preview Release\\Revit.exe")]
9+
810

911
namespace RevitTestLibrary.Demo.MSTestV3
1012
{
@@ -17,7 +19,7 @@ public void TestMethod_WriteLine()
1719
Console.WriteLine("This is a standard test");
1820
}
1921
[RevitTestMethod]
20-
public void Revit_TestMethod_WriteLine(UIApplication uia)
22+
public void Revit_TestMethod_WriteLine(RevitContext revitContext)
2123
{
2224
Console.WriteLine("This code is running inside Revit.");
2325
}
@@ -29,26 +31,26 @@ public void TestMethod_Fail()
2931
Assert.Fail("This is a standard test");
3032
}
3133
[RevitTestMethod]
32-
public void Revit_TestMethod_Fail(UIApplication uia)
34+
public void Revit_TestMethod_Fail(RevitContext revitContext)
3335
{
3436
Assert.Fail("This code is running inside Revit.");
3537
}
3638

3739

3840
[RevitTestMethod]
39-
public void Revit_CreateNewProjectDocument(UIApplication uia)
41+
public void Revit_CreateNewProjectDocument(RevitContext revitContext)
4042
{
41-
var document = uia.Application.NewProjectDocument(UnitSystem.Metric);
43+
var document = revitContext.UIApplication.Application.NewProjectDocument(UnitSystem.Metric);
4244
Console.WriteLine(document.Title);
4345
document.Close(false);
4446
}
4547

4648

4749
[RevitTestMethod]
48-
public void Revit_OpenProjectDocument(UIApplication uia)
50+
public void Revit_OpenProjectDocument(RevitContext revitContext)
4951
{
50-
var path = Path.Combine(GetTestDirectory(), @"..\..\assets\rst_basic_sample_project.rvt");
51-
var document = uia.Application.OpenDocumentFile(path);
52+
var path = Path.Combine(revitContext.TestAssemblyLocation, @"..\..\..\assets\rst_basic_sample_project.rvt");
53+
var document = revitContext.UIApplication.Application.OpenDocumentFile(path);
5254

5355
var collector = new FilteredElementCollector(document).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls);
5456
var count = collector.GetElementCount();
@@ -61,25 +63,16 @@ public void Revit_OpenProjectDocument(UIApplication uia)
6163
[RevitTestMethod]
6264
[DataRow(BuiltInCategory.OST_Walls, 9)]
6365
[DataRow(BuiltInCategory.OST_Columns, 0)]
64-
public void Revit_DataDrivenTest(UIApplication uia, BuiltInCategory inputCategory, int expectedCount)
66+
public void Revit_DataDrivenTest(RevitContext revitContext, BuiltInCategory inputCategory, int expectedCount)
6567
{
66-
var path = Path.Combine(GetTestDirectory(), @"..\..\assets\rst_basic_sample_project.rvt");
67-
var document = uia.Application.OpenDocumentFile(path);
68+
var path = Path.Combine(revitContext.TestAssemblyLocation, @"..\..\..\assets\rst_basic_sample_project.rvt");
69+
var document = revitContext.UIApplication.Application.OpenDocumentFile(path);
6870

6971
var collector = new FilteredElementCollector(document).WhereElementIsNotElementType().OfCategory(inputCategory);
7072
var count = collector.GetElementCount();
7173

7274
Assert.AreEqual(expectedCount, count);
7375
document.Close(false);
7476
}
75-
76-
77-
private static string GetTestDirectory()
78-
{
79-
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
80-
UriBuilder uri = new UriBuilder(codeBase);
81-
string path = Uri.UnescapeDataString(uri.Path);
82-
return Path.GetDirectoryName(path);
83-
}
8477
}
8578
}

sources/RevitTestLibrary.Demo.MSTestV3/app.config

Lines changed: 0 additions & 15 deletions
This file was deleted.
Binary file not shown.

sources/RevitTestLibrary.Demo.MSTestV3/packages.config

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)