aboutsummaryrefslogtreecommitdiff
path: root/src/burn/test/BurnUnitTest/LoggingTest.cpp
blob: ed74c875aaed426e8674f427f0085b965a4fa451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 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 Microsoft
{
namespace Tools
{
namespace WindowsInstallerXml
{
namespace Test
{
namespace Bootstrapper
{
    using namespace System;
    using namespace Xunit;

    public ref class LoggingTest : BurnUnitTest
    {
    public:
        LoggingTest(BurnTestFixture^ fixture) : BurnUnitTest(fixture)
        {
        }

        [Fact]
        void LoggingLoadXmlTest()
        {
            HRESULT hr = S_OK;
            IXMLDOMElement* pixeBundle = NULL;
            BURN_ENGINE_STATE engineState = { };
            try
            {
                LPCWSTR wzDocument =
                    L"<BurnManifest>"
                    L"    <Log PathVariable='WixBundleLog' Prefix='BundleA' Extension='.log' />"
                    L"</BurnManifest>";

                // logutil is static so there can only be one log active at a time.
                // 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.
                LogClose(FALSE);

                VariableInitialize(&engineState.variables);

                LoadBundleXmlHelper(wzDocument, &pixeBundle);

                hr = LoggingParseFromXml(&engineState.log, pixeBundle);
                NativeAssert::Succeeded(hr, L"Failed to parse logging from XML.");

                engineState.internalCommand.mode = BURN_MODE_NORMAL;

                hr = LoggingOpen(&engineState.log, &engineState.internalCommand, &engineState.command, &engineState.variables, L"BundleA");
                NativeAssert::Succeeded(hr, L"Failed to open logging.");

                Assert::True(VariableExistsHelper(&engineState.variables, L"WixBundleLog"));
            }
            finally
            {
                ReleaseObject(pixeBundle);
                LogClose(FALSE);
                LogOpen(NULL, L"BurnUnitTest", NULL, L"txt", FALSE, FALSE, NULL);
            }
        }
    };
}
}
}
}
}