Skip to content

Commit

Permalink
Merge pull request nunit#591 from agray/master
Browse files Browse the repository at this point in the history
Suggested fix for issue 22
  • Loading branch information
CharliePoole committed Apr 16, 2015
2 parents 8c28f74 + 62d32d4 commit 9b8f37e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/NUnitEngine/nunit.engine.tests/ResultHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2013 Charlie Poole
// Copyright (c) 2015 Charlie Poole
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -21,7 +21,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************

using System;
using System.Xml;

namespace NUnit.Engine.Internal.Tests
Expand All @@ -45,8 +44,8 @@ public void SetUp()
{
result1 = new TestEngineResult(resultText1);
result2 = new TestEngineResult(resultText2);
twoResults = new TestEngineResult[] { result1, result2 };
twoNodes = new XmlNode[] { result1.Xml, result2.Xml };
twoResults = new[] { result1, result2 };
twoNodes = new[] { result1.Xml, result2.Xml };
}

[Test]
Expand Down Expand Up @@ -133,6 +132,7 @@ public void InsertEnvironmentElement()
Assert.NotNull(env.GetAttribute("user-domain"));
Assert.NotNull(env.GetAttribute("culture"));
Assert.NotNull(env.GetAttribute("uiculture"));
Assert.NotNull(env.GetAttribute("os-architecture"));
}
}
}
}
27 changes: 19 additions & 8 deletions src/NUnitEngine/nunit.engine/Internal/ResultHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011 Charlie Poole
// Copyright (c) 2015 Charlie Poole
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -25,7 +25,6 @@
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Xml;

namespace NUnit.Engine.Internal
Expand All @@ -46,6 +45,10 @@ public static class ResultHelper
/// Aggregate the XmlNodes under a TestEngineResult into a single XmlNode.
/// </summary>
/// <param name="result">A new TestEngineResult with xml nodes for each assembly or project</param>
/// <param name="elementName"></param>
/// <param name="suiteType"></param>
/// <param name="name"></param>
/// <param name="fullname"></param>
/// <returns>A TestEngineResult with a single top-level element.</returns>
public static TestEngineResult Aggregate(this TestEngineResult result, string elementName, string suiteType, string name, string fullname)
{
Expand All @@ -56,6 +59,9 @@ public static TestEngineResult Aggregate(this TestEngineResult result, string el
/// Aggregate the XmlNodes under a TestEngineResult into a single XmlNode.
/// </summary>
/// <param name="result">A new TestEngineResult with xml nodes for each assembly or project</param>
/// <param name="elementName"></param>
/// <param name="name"></param>
/// <param name="fullname"></param>
/// <returns>A TestEngineResult with a single top-level element.</returns>
public static TestEngineResult Aggregate(this TestEngineResult result, string elementName, string name, string fullname)
{
Expand All @@ -81,9 +87,9 @@ public static TestEngineResult MakePackageResult(this TestEngineResult result, s
/// <param name="results">A list of TestEngineResults</param>
/// <returns>A TestEngineResult merging all the imput results</returns>
/// <remarks>Used by AbstractTestRunner MakePackageResult method.</remarks>
public static TestEngineResult Merge(IList<TestEngineResult> results)
public static TestEngineResult Merge(IList<TestEngineResult> results)
{
TestEngineResult mergedResult = new TestEngineResult();
var mergedResult = new TestEngineResult();

foreach (TestEngineResult result in results)
foreach (XmlNode node in result.XmlNodes)
Expand All @@ -99,7 +105,7 @@ public static TestEngineResult Merge(IList<TestEngineResult> results)
/// <summary>
/// Insert an environment element as a child of the node provided.
/// </summary>
/// <param name="resultNode"></param>
/// <param name="resultNode">Attribute to which environment element attributes will be added.</param>
public static void InsertEnvironmentElement(this XmlNode resultNode)
{
XmlNode env = resultNode.OwnerDocument.CreateElement("environment");
Expand All @@ -112,8 +118,13 @@ public static void InsertEnvironmentElement(this XmlNode resultNode)
env.AddAttribute("machine-name", Environment.MachineName);
env.AddAttribute("user", Environment.UserName);
env.AddAttribute("user-domain", Environment.UserDomainName);
env.AddAttribute("culture", System.Globalization.CultureInfo.CurrentCulture.ToString());
env.AddAttribute("uiculture", System.Globalization.CultureInfo.CurrentUICulture.ToString());
env.AddAttribute("culture", CultureInfo.CurrentCulture.ToString());
env.AddAttribute("uiculture", CultureInfo.CurrentUICulture.ToString());
env.AddAttribute("os-architecture", GetProcessorArchitecture());
}

private static string GetProcessorArchitecture() {
return IntPtr.Size == 8 ? "x64" : "x86";
}

#endregion
Expand Down Expand Up @@ -203,4 +214,4 @@ public static XmlNode Aggregate(string elementName, string testType, string name

#endregion
}
}
}

0 comments on commit 9b8f37e

Please sign in to comment.