From 4a176b759c47fa1970fcfd0d9e25c294bda82ef4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 22 Dec 2019 13:51:35 +1100 Subject: Update the MbaHost test project to use an external exe to load the BA, which allows loading a different .NET than the one running the tests. This also allows writing the tests in C# instead of C++/CLI. --- src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp | 70 ---------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp (limited to 'src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp') diff --git a/src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp b/src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp deleted file mode 100644 index 9328aacf..00000000 --- a/src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// 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" - -namespace WixToolsetTest -{ -namespace MbaHost -{ -namespace Native -{ - using namespace System; - using namespace Xunit; - - public ref class MbaHostFixture - { - public: - [Fact] - void CanLoadManagedBootstrapperApplication() - { - HMODULE hBAModule = NULL; - PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; - HRESULT hr = S_OK; - - EngineForTest^ engine = gcnew EngineForTest(); - BOOTSTRAPPER_ENGINE_CONTEXT engineContext = { }; - engineContext.pfnLog = engine->GetTestLogProc(); - - LogInitialize(::GetModuleHandleW(NULL)); - - hr = LogOpen(NULL, L"MbaHostUnitTest", NULL, L"txt", FALSE, FALSE, NULL); - Assert::Equal(S_OK, hr); - - BOOTSTRAPPER_COMMAND command = { }; - BOOTSTRAPPER_CREATE_ARGS args = { }; - BOOTSTRAPPER_CREATE_RESULTS results = { }; - - args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); - args.pCommand = &command; - args.pfnBootstrapperEngineProc = EngineForTestProc; - args.pvBootstrapperEngineProcContext = &engineContext; - args.qwEngineAPIVersion = MAKEQWORDVERSION(0, 0, 0, 1); - - results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); - - hBAModule = ::LoadLibraryExW(L"mbahost.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - Assert::NotEqual(NULL, (int)hBAModule); - - pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(hBAModule, "BootstrapperApplicationCreate"); - Assert::NotEqual(NULL, (int)pfnCreate); - - hr = pfnCreate(&args, &results); - Assert::Equal(S_OK, hr); - - BA_ONSHUTDOWN_ARGS shutdownArgs = { }; - BA_ONSHUTDOWN_RESULTS shutdownResults = { }; - shutdownArgs.cbSize = sizeof(BA_ONSHUTDOWN_ARGS); - shutdownResults.action = BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER; - shutdownResults.cbSize = sizeof(BA_ONSHUTDOWN_RESULTS); - hr = results.pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &shutdownArgs, &shutdownResults, results.pvBootstrapperApplicationProcContext); - Assert::Equal(S_OK, hr); - - List^ logMessages = engine->GetLogMessages(); - Assert::Equal(2, logMessages->Count); - Assert::Equal("Loading managed bootstrapper application.", logMessages[0]); - Assert::Equal("Shutdown,ReloadBootstrapper,0", logMessages[1]); - } - }; -} -} -} -- cgit v1.2.3-55-g6feb