From 4d94ed9fd1d9cb69337134561c520a24a91b91b2 Mon Sep 17 00:00:00 2001 From: Sean Hall <r.sean.hall@gmail.com> Date: Thu, 16 Jun 2022 14:41:27 -0500 Subject: Use dotnet test on C++/CLI test projects to get trx logs. --- .../burn/test/BalUtilUnitTest/BAFunctionsTests.cpp | 49 ++++++++++++++++++++++ .../test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 4 ++ .../BalUtilUnitTest.vcxproj.filters | 12 ++++++ .../BootstrapperApplicationTests.cpp | 45 ++++++++++++++++++++ .../burn/test/BalUtilUnitTest/TestBAFunctions.h | 10 +++++ .../BalUtilUnitTest/TestBootstrapperApplication.h | 9 ++++ src/api/burn/test/BalUtilUnitTest/precomp.h | 14 ++++--- 7 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp create mode 100644 src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp create mode 100644 src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h create mode 100644 src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h (limited to 'src/api/burn/test/BalUtilUnitTest') diff --git a/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp b/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp new file mode 100644 index 00000000..9920564e --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp @@ -0,0 +1,49 @@ +// 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. + +#include "precomp.h" + +using namespace System; +using namespace Xunit; +using namespace WixBuildTools::TestSupport; +using namespace WixBuildTools::TestSupport::XunitExtensions; + +namespace BalUtilTests +{ + public ref class BAFunctions + { + public: + [Fact] + void CanCreateTestBAFunctions() + { + HRESULT hr = S_OK; + BOOTSTRAPPER_CREATE_ARGS bootstrapperArgs = { }; + BOOTSTRAPPER_COMMAND bootstrapperCommand = { }; + BA_FUNCTIONS_CREATE_ARGS args = { }; + BA_FUNCTIONS_CREATE_RESULTS results = { }; + IBootstrapperEngine* pEngine = NULL; + IBAFunctions* pBAFunctions = NULL; + + bootstrapperArgs.cbSize = sizeof(bootstrapperArgs); + bootstrapperArgs.pCommand = &bootstrapperCommand; + + args.cbSize = sizeof(args); + args.pBootstrapperCreateArgs = &bootstrapperArgs; + + results.cbSize = sizeof(results); + + try + { + hr = BalInitializeFromCreateArgs(&bootstrapperArgs, &pEngine); + NativeAssert::Succeeded(hr, "Failed to create engine."); + + hr = CreateBAFunctions(NULL, pEngine, &args, &results, &pBAFunctions); + NativeAssert::Succeeded(hr, "Failed to create BAFunctions."); + } + finally + { + ReleaseObject(pEngine); + ReleaseObject(pBAFunctions); + } + } + }; +} diff --git a/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 113edeaa..d6c03a43 100644 --- a/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -37,6 +37,8 @@ </PropertyGroup> <ItemGroup> + <ClCompile Include="BAFunctionsTests.cpp" /> + <ClCompile Include="BootstrapperApplicationTests.cpp" /> <ClCompile Include="precomp.cpp"> <PrecompiledHeader>Create</PrecompiledHeader> <!-- Warnings from referencing netstandard dlls --> @@ -48,6 +50,8 @@ <ItemGroup> <ClInclude Include="precomp.h" /> + <ClInclude Include="TestBAFunctions.h" /> + <ClInclude Include="TestBootstrapperApplication.h" /> </ItemGroup> <ItemGroup> diff --git a/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters index 85f31076..0b3b60be 100644 --- a/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters +++ b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters @@ -15,6 +15,12 @@ </Filter> </ItemGroup> <ItemGroup> + <ClCompile Include="BAFunctionsTests.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="BootstrapperApplicationTests.cpp"> + <Filter>Source Files</Filter> + </ClCompile> <ClCompile Include="precomp.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -29,5 +35,11 @@ <ClInclude Include="precomp.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="TestBAFunctions.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="TestBootstrapperApplication.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> </Project> \ No newline at end of file diff --git a/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp b/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp new file mode 100644 index 00000000..396682ee --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp @@ -0,0 +1,45 @@ +// 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. + +#include "precomp.h" + +using namespace System; +using namespace Xunit; +using namespace WixBuildTools::TestSupport; +using namespace WixBuildTools::TestSupport::XunitExtensions; + +namespace BalUtilTests +{ + public ref class BootstrapperApplication + { + public: + [Fact] + void CanCreateTestBootstrapperApplication() + { + HRESULT hr = S_OK; + BOOTSTRAPPER_CREATE_ARGS args = { }; + BOOTSTRAPPER_COMMAND command = { }; + BOOTSTRAPPER_CREATE_RESULTS results = { }; + IBootstrapperEngine* pEngine = NULL; + IBootstrapperApplication* pApplication = NULL; + + args.cbSize = sizeof(args); + args.pCommand = &command; + + results.cbSize = sizeof(results); + + try + { + hr = BalInitializeFromCreateArgs(&args, &pEngine); + NativeAssert::Succeeded(hr, "Failed to create engine."); + + hr = CreateBootstrapperApplication(pEngine, &args, &results, &pApplication); + NativeAssert::Succeeded(hr, "Failed to create BootstrapperApplication."); + } + finally + { + ReleaseObject(pEngine); + ReleaseObject(pApplication); + } + } + }; +} diff --git a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h new file mode 100644 index 00000000..41f36df8 --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h @@ -0,0 +1,10 @@ +#pragma once +// 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. + +HRESULT CreateBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __in BA_FUNCTIONS_CREATE_RESULTS* pResults, + __out IBAFunctions** ppApplication + ); diff --git a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h new file mode 100644 index 00000000..c173e9ee --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h @@ -0,0 +1,9 @@ +#pragma once +// 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. + +HRESULT CreateBootstrapperApplication( + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults, + __out IBootstrapperApplication** ppApplication + ); diff --git a/src/api/burn/test/BalUtilUnitTest/precomp.h b/src/api/burn/test/BalUtilUnitTest/precomp.h index ce893906..218cab68 100644 --- a/src/api/burn/test/BalUtilUnitTest/precomp.h +++ b/src/api/burn/test/BalUtilUnitTest/precomp.h @@ -18,11 +18,15 @@ #include <BootstrapperEngine.h> #include <BootstrapperApplication.h> -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" -#include "balutil.h" -#include "balretry.h" -#include "BAFunctions.h" +#include <BAFunctions.h> +#include <IBootstrapperEngine.h> +#include <IBootstrapperApplication.h> +#include <IBAFunctions.h> +#include <balutil.h> +#include <balretry.h> + +#include "TestBAFunctions.h" +#include "TestBootstrapperApplication.h" #pragma managed #include <vcclr.h> -- cgit v1.2.3-55-g6feb