From fb4f8c7108f43d2341ba299424646c4963b21188 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 26 May 2022 17:33:15 -0500 Subject: Replace PathIsAbsolute with PathIsRooted and add PathIsFullyQualified. --- .../XunitExtensions/SpecificReturnCodeException.cs | 19 +++++++++++++++++++ .../XunitExtensions/WixAssert.cs | 8 ++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/internal/WixBuildTools.TestSupport/XunitExtensions/SpecificReturnCodeException.cs (limited to 'src/internal/WixBuildTools.TestSupport/XunitExtensions') 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 @@ +// 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. + +namespace WixBuildTools.TestSupport +{ + using System; + using Xunit.Sdk; + + public class SpecificReturnCodeException : XunitException + { + public SpecificReturnCodeException(int hr, string userMessage) + : base(String.Format("WixAssert.SpecificReturnCode() Failure\r\n" + + "HRESULT: 0x{0:X8}\r\n" + + "Message: {1}", + hr, userMessage)) + { + this.HResult = hr; + } + } +} 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 throw new SkipTestException(message); } + public static void SpecificReturnCode(int hrExpected, int hr, string format, params object[] formatArgs) + { + if (hrExpected != hr) + { + throw new SpecificReturnCodeException(hr, String.Format(format, formatArgs)); + } + } + public static void Succeeded(int hr, string format, params object[] formatArgs) { if (0 > hr) -- cgit v1.2.3-55-g6feb