diff options
Diffstat (limited to 'src/internal/WixBuildTools.TestSupport/XunitExtensions')
-rw-r--r-- | src/internal/WixBuildTools.TestSupport/XunitExtensions/SpecificReturnCodeException.cs | 19 | ||||
-rw-r--r-- | src/internal/WixBuildTools.TestSupport/XunitExtensions/WixAssert.cs | 8 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/internal/WixBuildTools.TestSupport/XunitExtensions/SpecificReturnCodeException.cs b/src/internal/WixBuildTools.TestSupport/XunitExtensions/SpecificReturnCodeException.cs new file mode 100644 index 00000000..c66890f8 --- /dev/null +++ b/src/internal/WixBuildTools.TestSupport/XunitExtensions/SpecificReturnCodeException.cs | |||
@@ -0,0 +1,19 @@ | |||
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 | namespace WixBuildTools.TestSupport | ||
4 | { | ||
5 | using System; | ||
6 | using Xunit.Sdk; | ||
7 | |||
8 | public class SpecificReturnCodeException : XunitException | ||
9 | { | ||
10 | public SpecificReturnCodeException(int hr, string userMessage) | ||
11 | : base(String.Format("WixAssert.SpecificReturnCode() Failure\r\n" + | ||
12 | "HRESULT: 0x{0:X8}\r\n" + | ||
13 | "Message: {1}", | ||
14 | hr, userMessage)) | ||
15 | { | ||
16 | this.HResult = hr; | ||
17 | } | ||
18 | } | ||
19 | } | ||
diff --git a/src/internal/WixBuildTools.TestSupport/XunitExtensions/WixAssert.cs b/src/internal/WixBuildTools.TestSupport/XunitExtensions/WixAssert.cs index 10156547..1ede55b3 100644 --- a/src/internal/WixBuildTools.TestSupport/XunitExtensions/WixAssert.cs +++ b/src/internal/WixBuildTools.TestSupport/XunitExtensions/WixAssert.cs | |||
@@ -52,6 +52,14 @@ namespace WixBuildTools.TestSupport | |||
52 | throw new SkipTestException(message); | 52 | throw new SkipTestException(message); |
53 | } | 53 | } |
54 | 54 | ||
55 | public static void SpecificReturnCode(int hrExpected, int hr, string format, params object[] formatArgs) | ||
56 | { | ||
57 | if (hrExpected != hr) | ||
58 | { | ||
59 | throw new SpecificReturnCodeException(hr, String.Format(format, formatArgs)); | ||
60 | } | ||
61 | } | ||
62 | |||
55 | public static void Succeeded(int hr, string format, params object[] formatArgs) | 63 | public static void Succeeded(int hr, string format, params object[] formatArgs) |
56 | { | 64 | { |
57 | if (0 > hr) | 65 | if (0 > hr) |