Skip to content

Commit

Permalink
Force invariant culture for some ColorTranslator tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mellinoe committed Jun 13, 2017
1 parent c58e53e commit b039537
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/System.Drawing.Common/tests/ColorTranslatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Threading;
using Xunit;

namespace System.Drawing.Tests
Expand Down Expand Up @@ -188,7 +190,16 @@ public static IEnumerable<object[]> FromHtml_TestData()
[MemberData(nameof(FromHtml_TestData))]
public void FromHtml_String_ReturnsExpected(string htmlColor, Color expected)
{
Assert.Equal(expected, ColorTranslator.FromHtml(htmlColor));
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
try
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Assert.Equal(expected, ColorTranslator.FromHtml(htmlColor));
}
finally
{
Thread.CurrentThread.CurrentCulture = originalCulture;
}
}

[Theory]
Expand Down Expand Up @@ -216,7 +227,16 @@ public void FromHtml_String_ReturnsExpected(string htmlColor, Color expected)
[InlineData("1,2,256", typeof(ArgumentException))]
public void FromHtml_Invalid_Throws(string htmlColor, Type exception)
{
Assert.Throws(exception, () => ColorTranslator.FromHtml(htmlColor));
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
try
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Assert.Throws(exception, () => ColorTranslator.FromHtml(htmlColor));
}
finally
{
Thread.CurrentThread.CurrentCulture = originalCulture;
}
}

public static IEnumerable<object[]> ToHtml_TestData()
Expand Down

0 comments on commit b039537

Please sign in to comment.