aboutsummaryrefslogtreecommitdiff
path: root/src/WixBuildTools.TestSupport.Native
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-07-15 16:47:24 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-07-16 16:40:52 +1000
commit64deb692cd9f690e3ce5560530fe93d7f0e3cd67 (patch)
tree9be14c60e213a6e045fb8c0a303b63e65aeaa118 /src/WixBuildTools.TestSupport.Native
parent1d77b037520a804a1d8f586faad86619b291a1a9 (diff)
downloadwix-64deb692cd9f690e3ce5560530fe93d7f0e3cd67.tar.gz
wix-64deb692cd9f690e3ce5560530fe93d7f0e3cd67.tar.bz2
wix-64deb692cd9f690e3ce5560530fe93d7f0e3cd67.zip
Add WixBuildTools.TestSupport.Native.
Diffstat (limited to 'src/WixBuildTools.TestSupport.Native')
-rw-r--r--src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp17
-rw-r--r--src/WixBuildTools.TestSupport.Native/NativeAssert.h85
-rw-r--r--src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj60
-rw-r--r--src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters33
-rw-r--r--src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props29
-rw-r--r--src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets15
-rw-r--r--src/WixBuildTools.TestSupport.Native/packages.config12
-rw-r--r--src/WixBuildTools.TestSupport.Native/precomp.cpp3
-rw-r--r--src/WixBuildTools.TestSupport.Native/precomp.h11
9 files changed, 265 insertions, 0 deletions
diff --git a/src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp b/src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp
new file mode 100644
index 00000000..23a48993
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/AssemblyInfo.cpp
@@ -0,0 +1,17 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3#include "precomp.h"
4
5using namespace System::Reflection;
6using namespace System::Runtime::CompilerServices;
7using namespace System::Runtime::InteropServices;
8
9//
10// General Information about an assembly is controlled through the following
11// set of attributes. Change these attribute values to modify the information
12// associated with an assembly.
13//
14[assembly: AssemblyTitleAttribute("WixBuildTools.TestSupport.Native")];
15[assembly: AssemblyDescriptionAttribute("")];
16[assembly: AssemblyCultureAttribute("")];
17[assembly: ComVisible(false)];
diff --git a/src/WixBuildTools.TestSupport.Native/NativeAssert.h b/src/WixBuildTools.TestSupport.Native/NativeAssert.h
new file mode 100644
index 00000000..34af4f34
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/NativeAssert.h
@@ -0,0 +1,85 @@
1#pragma once
2// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
3
4
5namespace WixBuildTools {
6namespace TestSupport {
7
8 using namespace System;
9 using namespace System::Collections::Generic;
10 using namespace System::Linq;
11 using namespace Xunit;
12
13 public ref class NativeAssert : WixAssert
14 {
15 public:
16 static void NotNull(LPCWSTR wz)
17 {
18 if (!wz)
19 {
20 Assert::NotNull(nullptr);
21 }
22 }
23
24 // For some reason, naming these NotStringEqual methods "NotEqual" breaks Intellisense in files that call any overload of the NotEqual method.
25 static void NotStringEqual(LPCWSTR expected, LPCWSTR actual)
26 {
27 NativeAssert::NotStringEqual(expected, actual, FALSE);
28 }
29
30 static void NotStringEqual(LPCWSTR expected, LPCWSTR actual, BOOL ignoreCase)
31 {
32 IEqualityComparer<String^>^ comparer = ignoreCase ? StringComparer::InvariantCultureIgnoreCase : StringComparer::InvariantCulture;
33 Assert::NotEqual(NativeAssert::LPWSTRToString(expected), NativeAssert::LPWSTRToString(actual), comparer);
34 }
35
36 // For some reason, naming these StringEqual methods "Equal" breaks Intellisense in files that call any overload of the Equal method.
37 static void StringEqual(LPCWSTR expected, LPCWSTR actual)
38 {
39 NativeAssert::StringEqual(expected, actual, FALSE);
40 }
41
42 static void StringEqual(LPCWSTR expected, LPCWSTR actual, BOOL ignoreCase)
43 {
44 IEqualityComparer<String^>^ comparer = ignoreCase ? StringComparer::InvariantCultureIgnoreCase : StringComparer::InvariantCulture;
45 Assert::Equal(NativeAssert::LPWSTRToString(expected), NativeAssert::LPWSTRToString(actual), comparer);
46 }
47
48 static void Succeeded(HRESULT hr, LPCSTR zFormat, LPCSTR zArg, ... array<LPCSTR>^ zArgs)
49 {
50 array<Object^>^ formatArgs = gcnew array<Object^, 1>(zArgs->Length + 1);
51 formatArgs[0] = NativeAssert::LPSTRToString(zArg);
52 for (int i = 0; i < zArgs->Length; ++i)
53 {
54 formatArgs[i + 1] = NativeAssert::LPSTRToString(zArgs[i]);
55 }
56 WixAssert::Succeeded(hr, gcnew String(zFormat), formatArgs);
57 }
58
59 static void Succeeded(HRESULT hr, LPCSTR zFormat, ... array<LPCWSTR>^ wzArgs)
60 {
61 array<Object^>^ formatArgs = gcnew array<Object^, 1>(wzArgs->Length);
62 for (int i = 0; i < wzArgs->Length; ++i)
63 {
64 formatArgs[i] = NativeAssert::LPWSTRToString(wzArgs[i]);
65 }
66 WixAssert::Succeeded(hr, gcnew String(zFormat), formatArgs);
67 }
68
69 static void ValidReturnCode(HRESULT hr, ... array<HRESULT>^ validReturnCodes)
70 {
71 Assert::Contains(hr, (IEnumerable<HRESULT>^)validReturnCodes);
72 }
73
74 private:
75 static String^ LPSTRToString(LPCSTR z)
76 {
77 return z ? gcnew String(z) : nullptr;
78 }
79 static String^ LPWSTRToString(LPCWSTR wz)
80 {
81 return wz ? gcnew String(wz) : nullptr;
82 }
83 };
84}
85}
diff --git a/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj
new file mode 100644
index 00000000..9f58a0bd
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj
@@ -0,0 +1,60 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6 <Import Project="build\WixBuildTools.TestSupport.Native.props" />
7 <ItemGroup Label="ProjectConfigurations">
8 <ProjectConfiguration Include="Debug|Win32">
9 <Configuration>Debug</Configuration>
10 <Platform>Win32</Platform>
11 </ProjectConfiguration>
12 <ProjectConfiguration Include="Release|Win32">
13 <Configuration>Release</Configuration>
14 <Platform>Win32</Platform>
15 </ProjectConfiguration>
16 </ItemGroup>
17 <PropertyGroup Label="Globals">
18 <ProjectTypes>{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</ProjectTypes>
19 <ProjectGuid>{95BABD97-FBDB-453A-AF8A-FA031A07B599}</ProjectGuid>
20 <RootNamespace>WixBuildTools::TestSupport</RootNamespace>
21 <Keyword>ManagedCProj</Keyword>
22 <ConfigurationType>DynamicLibrary</ConfigurationType>
23 <CharacterSet>Unicode</CharacterSet>
24 <CLRSupport>true</CLRSupport>
25 </PropertyGroup>
26 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
28 <PropertyGroup>
29 <ProjectAdditionalIncludeDirectories>
30 </ProjectAdditionalIncludeDirectories>
31 <ProjectAdditionalLinkLibraries>
32 </ProjectAdditionalLinkLibraries>
33 </PropertyGroup>
34 <ItemGroup>
35 <ClCompile Include="AssemblyInfo.cpp" />
36 <ClCompile Include="precomp.cpp">
37 <PrecompiledHeader>Create</PrecompiledHeader>
38 <!-- Warnings from NativeAssert.h from referencing netstandard dlls -->
39 <DisableSpecificWarnings>4564;4691</DisableSpecificWarnings>
40 </ClCompile>
41 </ItemGroup>
42 <ItemGroup>
43 <ClInclude Include="precomp.h" />
44 <ClInclude Include="NativeAssert.h" />
45 </ItemGroup>
46 <ItemGroup>
47 <None Include="packages.config" />
48 </ItemGroup>
49 <ItemGroup>
50 <Reference Include="System" />
51 <Reference Include="System.Core" />
52 </ItemGroup>
53 <ItemGroup>
54 <ProjectReference Include="..\WixBuildTools.TestSupport\WixBuildTools.TestSupport.csproj">
55 <Project>{6C57EF2C-979A-4106-A9E5-FE342810619A}</Project>
56 </ProjectReference>
57 </ItemGroup>
58 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
59 <Import Project="build\WixBuildTools.TestSupport.Native.targets" />
60</Project> \ No newline at end of file
diff --git a/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters
new file mode 100644
index 00000000..34c1380f
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/WixBuildTools.TestSupport.Native.vcxproj.filters
@@ -0,0 +1,33 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <ItemGroup>
4 <Filter Include="Source Files">
5 <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6 <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7 </Filter>
8 <Filter Include="Header Files">
9 <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10 <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11 </Filter>
12 <Filter Include="Resource Files">
13 <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14 <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15 </Filter>
16 </ItemGroup>
17 <ItemGroup>
18 <ClInclude Include="precomp.h">
19 <Filter>Header Files</Filter>
20 </ClInclude>
21 <ClInclude Include="NativeAssert.h">
22 <Filter>Header Files</Filter>
23 </ClInclude>
24 </ItemGroup>
25 <ItemGroup>
26 <ClCompile Include="AssemblyInfo.cpp">
27 <Filter>Source Files</Filter>
28 </ClCompile>
29 <ClCompile Include="precomp.cpp">
30 <Filter>Source Files</Filter>
31 </ClCompile>
32 </ItemGroup>
33</Project> \ No newline at end of file
diff --git a/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props
new file mode 100644
index 00000000..4a7a0035
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.props
@@ -0,0 +1,29 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6 <PropertyGroup>
7 <RepoRootDir Condition=" '$(RepoRootDir)' == '' ">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), version.json))</RepoRootDir>
8 </PropertyGroup>
9 <Import Project="$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.props" Condition="Exists('$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.props')" />
10 <Import Project="$(RepoRootDir)\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('$(RepoRootDir)\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props')" />
11 <PropertyGroup>
12 <PlatformToolset>v142</PlatformToolset>
13 <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
14 </PropertyGroup>
15 <ItemGroup>
16 <Reference Include="xunit.abstractions">
17 <HintPath>$(RepoRootDir)\packages\xunit.abstractions.2.0.3\lib\netstandard2.0\xunit.abstractions.dll</HintPath>
18 </Reference>
19 <Reference Include="xunit.assert">
20 <HintPath>$(RepoRootDir)\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
21 </Reference>
22 <Reference Include="xunit.core">
23 <HintPath>$(RepoRootDir)\packages\xunit.extensibility.core.2.4.1\lib\netstandard1.1\xunit.core.dll</HintPath>
24 </Reference>
25 <Reference Include="xunit.execution.desktop">
26 <HintPath>$(RepoRootDir)\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll</HintPath>
27 </Reference>
28 </ItemGroup>
29</Project> \ No newline at end of file
diff --git a/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets
new file mode 100644
index 00000000..09746229
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets
@@ -0,0 +1,15 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6 <Import Project="$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.targets" Condition="Exists('$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.targets')" />
7 <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
8 <PropertyGroup>
9 <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>
10 </PropertyGroup>
11 <Error Condition="!Exists('$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.props'))" />
12 <Error Condition="!Exists('$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(RepoRootDir)\packages\xunit.core.2.4.1\build\xunit.core.targets'))" />
13 <Error Condition="!Exists('$(RepoRootDir)\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '$(RepoRootDir)\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props'))" />
14 </Target>
15</Project> \ No newline at end of file
diff --git a/src/WixBuildTools.TestSupport.Native/packages.config b/src/WixBuildTools.TestSupport.Native/packages.config
new file mode 100644
index 00000000..b62d37e6
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/packages.config
@@ -0,0 +1,12 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
5<packages>
6 <package id="xunit.abstractions" version="2.0.3" />
7 <package id="xunit.assert" version="2.4.1" />
8 <package id="xunit.core" version="2.4.1" />
9 <package id="xunit.extensibility.core" version="2.4.1" />
10 <package id="xunit.extensibility.execution" version="2.4.1" />
11 <package id="xunit.runner.visualstudio" version="2.4.1" />
12</packages>
diff --git a/src/WixBuildTools.TestSupport.Native/precomp.cpp b/src/WixBuildTools.TestSupport.Native/precomp.cpp
new file mode 100644
index 00000000..37664a1c
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/precomp.cpp
@@ -0,0 +1,3 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3#include "precomp.h"
diff --git a/src/WixBuildTools.TestSupport.Native/precomp.h b/src/WixBuildTools.TestSupport.Native/precomp.h
new file mode 100644
index 00000000..f54b55be
--- /dev/null
+++ b/src/WixBuildTools.TestSupport.Native/precomp.h
@@ -0,0 +1,11 @@
1#pragma once
2// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
3
4
5#include <windows.h>
6#include <strsafe.h>
7
8#include "NativeAssert.h"
9
10#pragma managed
11#include <vcclr.h>