aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/test/DUtilUnitTest/ApupUtilTests.cpp
blob: c2371636af6acee67b5d404ca5472235f5b437ae (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
// 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);
                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();
            }
        }
    };
}