Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Fix non-deterministic failure in ColorTests (#21005)
Browse files Browse the repository at this point in the history
If GetProperties returns items in different orders on multiple calls, it's possible for at least one of the tests to fail.  Just cache the results.
  • Loading branch information
stephentoub authored Jun 13, 2017
1 parent d7d59a6 commit 3875f5c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/System.Drawing.Primitives/tests/ColorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace System.Drawing.Primitives.Tests
{
public partial class ColorTests
{
public static IEnumerable<object[]> NamedArgbValues =>
public static readonly IEnumerable<object[]> NamedArgbValues =
new[]
{
new object[] {"Transparent", 0, 255, 255, 255},
Expand Down Expand Up @@ -157,9 +157,10 @@ public partial class ColorTests
new object[] {"YellowGreen", 255, 154, 205, 50},
};

public static IEnumerable<object[]> ColorNames => typeof(Color).GetProperties()
public static readonly IEnumerable<object[]> ColorNames = typeof(Color).GetProperties()
.Where(p => p.PropertyType == typeof(Color))
.Select(p => new object[] { p.Name} );
.Select(p => new object[] { p.Name })
.ToArray();

private Color? GetColorByProperty(string name)
{
Expand Down

0 comments on commit 3875f5c

Please sign in to comment.