diff options
Diffstat (limited to 'src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp')
| -rw-r--r-- | src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp b/src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp new file mode 100644 index 00000000..9328aacf --- /dev/null +++ b/src/test/WixToolsetTest.MbaHost/MbaHostFixture.cpp | |||
| @@ -0,0 +1,70 @@ | |||
| 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 | |||
| 5 | namespace WixToolsetTest | ||
| 6 | { | ||
| 7 | namespace MbaHost | ||
| 8 | { | ||
| 9 | namespace Native | ||
| 10 | { | ||
| 11 | using namespace System; | ||
| 12 | using namespace Xunit; | ||
| 13 | |||
| 14 | public ref class MbaHostFixture | ||
| 15 | { | ||
| 16 | public: | ||
| 17 | [Fact] | ||
| 18 | void CanLoadManagedBootstrapperApplication() | ||
| 19 | { | ||
| 20 | HMODULE hBAModule = NULL; | ||
| 21 | PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; | ||
| 22 | HRESULT hr = S_OK; | ||
| 23 | |||
| 24 | EngineForTest^ engine = gcnew EngineForTest(); | ||
| 25 | BOOTSTRAPPER_ENGINE_CONTEXT engineContext = { }; | ||
| 26 | engineContext.pfnLog = engine->GetTestLogProc(); | ||
| 27 | |||
| 28 | LogInitialize(::GetModuleHandleW(NULL)); | ||
| 29 | |||
| 30 | hr = LogOpen(NULL, L"MbaHostUnitTest", NULL, L"txt", FALSE, FALSE, NULL); | ||
| 31 | Assert::Equal(S_OK, hr); | ||
| 32 | |||
| 33 | BOOTSTRAPPER_COMMAND command = { }; | ||
| 34 | BOOTSTRAPPER_CREATE_ARGS args = { }; | ||
| 35 | BOOTSTRAPPER_CREATE_RESULTS results = { }; | ||
| 36 | |||
| 37 | args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); | ||
| 38 | args.pCommand = &command; | ||
| 39 | args.pfnBootstrapperEngineProc = EngineForTestProc; | ||
| 40 | args.pvBootstrapperEngineProcContext = &engineContext; | ||
| 41 | args.qwEngineAPIVersion = MAKEQWORDVERSION(0, 0, 0, 1); | ||
| 42 | |||
| 43 | results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); | ||
| 44 | |||
| 45 | hBAModule = ::LoadLibraryExW(L"mbahost.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH); | ||
| 46 | Assert::NotEqual(NULL, (int)hBAModule); | ||
| 47 | |||
| 48 | pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(hBAModule, "BootstrapperApplicationCreate"); | ||
| 49 | Assert::NotEqual(NULL, (int)pfnCreate); | ||
| 50 | |||
| 51 | hr = pfnCreate(&args, &results); | ||
| 52 | Assert::Equal(S_OK, hr); | ||
| 53 | |||
| 54 | BA_ONSHUTDOWN_ARGS shutdownArgs = { }; | ||
| 55 | BA_ONSHUTDOWN_RESULTS shutdownResults = { }; | ||
| 56 | shutdownArgs.cbSize = sizeof(BA_ONSHUTDOWN_ARGS); | ||
| 57 | shutdownResults.action = BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER; | ||
| 58 | shutdownResults.cbSize = sizeof(BA_ONSHUTDOWN_RESULTS); | ||
| 59 | hr = results.pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &shutdownArgs, &shutdownResults, results.pvBootstrapperApplicationProcContext); | ||
| 60 | Assert::Equal(S_OK, hr); | ||
| 61 | |||
| 62 | List<String^>^ logMessages = engine->GetLogMessages(); | ||
| 63 | Assert::Equal(2, logMessages->Count); | ||
| 64 | Assert::Equal("Loading managed bootstrapper application.", logMessages[0]); | ||
| 65 | Assert::Equal("Shutdown,ReloadBootstrapper,0", logMessages[1]); | ||
| 66 | } | ||
| 67 | }; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
