diff options
Diffstat (limited to '')
| -rw-r--r-- | src/burn/test/BurnUnitTest/LoggingTest.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/burn/test/BurnUnitTest/LoggingTest.cpp b/src/burn/test/BurnUnitTest/LoggingTest.cpp new file mode 100644 index 00000000..ed74c875 --- /dev/null +++ b/src/burn/test/BurnUnitTest/LoggingTest.cpp | |||
| @@ -0,0 +1,68 @@ | |||
| 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 Microsoft | ||
| 6 | { | ||
| 7 | namespace Tools | ||
| 8 | { | ||
| 9 | namespace WindowsInstallerXml | ||
| 10 | { | ||
| 11 | namespace Test | ||
| 12 | { | ||
| 13 | namespace Bootstrapper | ||
| 14 | { | ||
| 15 | using namespace System; | ||
| 16 | using namespace Xunit; | ||
| 17 | |||
| 18 | public ref class LoggingTest : BurnUnitTest | ||
| 19 | { | ||
| 20 | public: | ||
| 21 | LoggingTest(BurnTestFixture^ fixture) : BurnUnitTest(fixture) | ||
| 22 | { | ||
| 23 | } | ||
| 24 | |||
| 25 | [Fact] | ||
| 26 | void LoggingLoadXmlTest() | ||
| 27 | { | ||
| 28 | HRESULT hr = S_OK; | ||
| 29 | IXMLDOMElement* pixeBundle = NULL; | ||
| 30 | BURN_ENGINE_STATE engineState = { }; | ||
| 31 | try | ||
| 32 | { | ||
| 33 | LPCWSTR wzDocument = | ||
| 34 | L"<BurnManifest>" | ||
| 35 | L" <Log PathVariable='WixBundleLog' Prefix='BundleA' Extension='.log' />" | ||
| 36 | L"</BurnManifest>"; | ||
| 37 | |||
| 38 | // logutil is static so there can only be one log active at a time. | ||
| 39 | // This test needs to open a log so need to close the default one for the tests and then open a new one at the end for the tests that run after this one. | ||
| 40 | LogClose(FALSE); | ||
| 41 | |||
| 42 | VariableInitialize(&engineState.variables); | ||
| 43 | |||
| 44 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | ||
| 45 | |||
| 46 | hr = LoggingParseFromXml(&engineState.log, pixeBundle); | ||
| 47 | NativeAssert::Succeeded(hr, L"Failed to parse logging from XML."); | ||
| 48 | |||
| 49 | engineState.internalCommand.mode = BURN_MODE_NORMAL; | ||
| 50 | |||
| 51 | hr = LoggingOpen(&engineState.log, &engineState.internalCommand, &engineState.command, &engineState.variables, L"BundleA"); | ||
| 52 | NativeAssert::Succeeded(hr, L"Failed to open logging."); | ||
| 53 | |||
| 54 | Assert::True(VariableExistsHelper(&engineState.variables, L"WixBundleLog")); | ||
| 55 | } | ||
| 56 | finally | ||
| 57 | { | ||
| 58 | ReleaseObject(pixeBundle); | ||
| 59 | LogClose(FALSE); | ||
| 60 | LogOpen(NULL, L"BurnUnitTest", NULL, L"txt", FALSE, FALSE, NULL); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | }; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
