main
cpp 60 lines 1.87 KB
Raw
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 using namespace System;
6 using namespace Xunit;
7 using namespace WixInternal::TestSupport;
8
9 namespace DutilTests
10 {
11 public ref class GuidUtil
12 {
13 public:
14 [Fact]
15 void GuidCreateTest()
16 {
17 HRESULT hr = S_OK;
18 WCHAR wzGuid1[GUID_STRING_LENGTH];
19 WCHAR wzGuid2[GUID_STRING_LENGTH];
20
21 hr = GuidFixedCreate(wzGuid1);
22 NativeAssert::Succeeded(hr, "Failed to create first guid.");
23 Guid firstGuid = Guid::Parse(gcnew String(wzGuid1));
24
25 hr = GuidFixedCreate(wzGuid2);
26 NativeAssert::Succeeded(hr, "Failed to create second guid.");
27 Guid secondGuid = Guid::Parse(gcnew String(wzGuid2));
28
29 NativeAssert::NotStringEqual(wzGuid1, wzGuid2);
30 NativeAssert::NotEqual(firstGuid, secondGuid);
31 }
32
33 [Fact]
34 void GuidCreateSczTest()
35 {
36 HRESULT hr = S_OK;
37 LPWSTR sczGuid1 = NULL;
38 LPWSTR sczGuid2 = NULL;
39
40 try
41 {
42 hr = GuidCreate(&sczGuid1);
43 NativeAssert::Succeeded(hr, "Failed to create first guid.");
44 Guid firstGuid = Guid::Parse(gcnew String(sczGuid1));
45
46 hr = GuidCreate(&sczGuid2);
47 NativeAssert::Succeeded(hr, "Failed to create second guid.");
48 Guid secondGuid = Guid::Parse(gcnew String(sczGuid2));
49
50 NativeAssert::NotStringEqual(sczGuid1, sczGuid2);
51 NativeAssert::NotEqual(firstGuid, secondGuid);
52 }
53 finally
54 {
55 ReleaseStr(sczGuid1);
56 ReleaseStr(sczGuid2);
57 }
58 }
59 };
60 }