aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/test/DUtilUnitTest/ApupUtilTests.cpp
blob: 2a2de4ac42190fefb7e4a8550f0bcc3d1292155f (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
// 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 WixInternal::TestSupport;

namespace DutilTests
{
    public ref class ApupUtil
    {
    public:
        [Fact]
        void AllocChainFromAtomSortsDescending()
        {
            HRESULT hr = S_OK;
            ATOM_FEED* pFeed = NULL;
            APPLICATION_UPDATE_CHAIN* pChain = NULL;

            DutilInitialize(&DutilTestTraceError);

            try
            {
                XmlInitialize();
                NativeAssert::Succeeded(hr, "Failed to initialize Xml.");

                pin_ptr<const wchar_t> feedFilePath = PtrToStringChars(TestData::Get("TestData", "ApupUtilTests", "FeedBv2.0.xml"));
                hr = AtomParseFromFile(feedFilePath, &pFeed);

                if (REGDB_E_CLASSNOTREG == hr)
                {
                    // Annoying and weird error shouldn't fail the build.
                    return;
                }
                NativeAssert::Succeeded(hr, "Failed to parse feed: {0}", feedFilePath);

                hr = ApupAllocChainFromAtom(pFeed, &pChain);
                NativeAssert::Succeeded(hr, "Failed to get chain from feed.");

                Assert::Equal(3ul, pChain->cEntries);
                NativeAssert::StringEqual(L"Bundle v2.0", pChain->rgEntries[0].wzTitle);
                NativeAssert::StringEqual(L"Bundle v1.0", pChain->rgEntries[1].wzTitle);
                NativeAssert::StringEqual(L"Bundle v1.0-preview", pChain->rgEntries[2].wzTitle);
            }
            finally
            {
                DutilUninitialize();
            }
        }
    };
}