aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.TestPackage/WixRunnerResult.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.TestPackage/WixRunnerResult.cs')
-rw-r--r--src/WixToolset.Core.TestPackage/WixRunnerResult.cs24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/WixToolset.Core.TestPackage/WixRunnerResult.cs b/src/WixToolset.Core.TestPackage/WixRunnerResult.cs
index 8fc7e14f..f4870ae3 100644
--- a/src/WixToolset.Core.TestPackage/WixRunnerResult.cs
+++ b/src/WixToolset.Core.TestPackage/WixRunnerResult.cs
@@ -1,9 +1,9 @@
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. 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 2
3namespace WixToolset.Core.TestPackage 3namespace WixToolset.Core.TestPackage
4{ 4{
5 using System; 5 using System;
6 using System.Linq; 6 using System.Collections.Generic;
7 using WixToolset.Data; 7 using WixToolset.Data;
8 using Xunit; 8 using Xunit;
9 9
@@ -15,8 +15,26 @@ namespace WixToolset.Core.TestPackage
15 15
16 public WixRunnerResult AssertSuccess() 16 public WixRunnerResult AssertSuccess()
17 { 17 {
18 Assert.True(0 == this.ExitCode, $"\r\n\r\nWixRunner failed with exit code: {this.ExitCode}\r\n Output: {String.Join("\r\n ", this.Messages.Select(m => m.ToString()).ToArray())}\r\n"); 18 Assert.True(0 == this.ExitCode, $"\r\n\r\nWixRunner failed with exit code: {this.ExitCode}\r\n Output: {String.Join("\r\n ", FormatMessages(this.Messages))}\r\n");
19 return this; 19 return this;
20 } 20 }
21
22 private static IEnumerable<string> FormatMessages(IEnumerable<Message> messages)
23 {
24 foreach (var message in messages)
25 {
26 var filename = message.SourceLineNumbers?.FileName ?? "TEST";
27 var line = message.SourceLineNumbers?.LineNumber ?? -1;
28 var type = message.Level.ToString().ToLowerInvariant();
29 var output = message.Level >= MessageLevel.Warning ? Console.Out : Console.Error;
30
31 if (line > 0)
32 {
33 filename = String.Concat(filename, "(", line, ")");
34 }
35
36 yield return String.Format("{0} : {1} {2}{3:0000}: {4}", filename, type, "TEST", message.Id, message.ToString());
37 }
38 }
21 } 39 }
22} 40}