From 1d77b037520a804a1d8f586faad86619b291a1a9 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 12 Jul 2020 10:31:24 +1000 Subject: Add WixAssert and SucceededException. --- src/WixBuildTools.TestSupport/SucceededException.cs | 18 ++++++++++++++++++ src/WixBuildTools.TestSupport/WixAssert.cs | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/WixBuildTools.TestSupport/SucceededException.cs create mode 100644 src/WixBuildTools.TestSupport/WixAssert.cs diff --git a/src/WixBuildTools.TestSupport/SucceededException.cs b/src/WixBuildTools.TestSupport/SucceededException.cs new file mode 100644 index 00000000..00b31d68 --- /dev/null +++ b/src/WixBuildTools.TestSupport/SucceededException.cs @@ -0,0 +1,18 @@ +// 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 SucceededException : XunitException + { + public SucceededException(int hr, string userMessage) + : base(String.Format("WixAssert.Succeeded() Failure\r\n" + + "HRESULT: 0x{0:X8}\r\n" + + "Message: {1}", + hr, userMessage)) + { + } + } +} diff --git a/src/WixBuildTools.TestSupport/WixAssert.cs b/src/WixBuildTools.TestSupport/WixAssert.cs new file mode 100644 index 00000000..4a5c6a97 --- /dev/null +++ b/src/WixBuildTools.TestSupport/WixAssert.cs @@ -0,0 +1,18 @@ +// 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; + + public class WixAssert : Assert + { + public static void Succeeded(int hr, string format, params object[] formatArgs) + { + if (0 > hr) + { + throw new SucceededException(hr, String.Format(format, formatArgs)); + } + } + } +} -- cgit v1.2.3-55-g6feb