main
cpp 64 lines 1.83 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 using namespace WixInternal::TestSupport::XunitExtensions;
9
10 namespace DutilTests
11 {
12 [Collection("Dutil_TraceErrorSource")]
13 public ref class DUtil
14 {
15 public:
16 [SkippableFact]
17 void DUtilTraceErrorSourceFiltersOnTraceLevel()
18 {
19 DutilInitialize(&DutilTestTraceError);
20
21 try
22 {
23 CallDutilTraceErrorSource();
24
25 Dutil_TraceSetLevel(REPORT_DEBUG, FALSE);
26
27 Exception^ traceErrorException = nullptr;
28
29 try
30 {
31 CallDutilTraceErrorSource();
32 }
33 catch (Exception^ e)
34 {
35 traceErrorException = e;
36 }
37
38 if (traceErrorException == nullptr)
39 {
40 WixAssert::Skip("Dutil_TraceErrorSource did not call the registered callback.");
41 }
42 else
43 {
44 WixAssert::StringEqual("hr = 0x80004005, message = Error message", traceErrorException->Message, false);
45 }
46 }
47 finally
48 {
49 DutilUninitialize();
50 }
51 }
52
53 private:
54 void CallDutilTraceErrorSource()
55 {
56 Dutil_TraceErrorSource(__FILE__, __LINE__, REPORT_DEBUG, DUTIL_SOURCE_EXTERNAL, E_FAIL, "Error message");
57 }
58 };
59
60 [CollectionDefinition("Dutil_TraceErrorSource", DisableParallelization = true)]
61 public ref class Dutil_TraceErrorSourceCollectionDefinition
62 {
63 };
64 }