From 6b6d9135298500a753b3393b1c7cc4aa94617aa2 Mon Sep 17 00:00:00 2001 From: Roman Marusyk Date: Fri, 29 Nov 2019 07:53:09 +0100 Subject: [PATCH] Consolidate .netcoreapp.cs files because projects is no longer cross-compiled (#392) --- .../System.Drawing.Primitives/tests/ColorTests.cs | 168 ++++++++++++++- .../tests/ColorTests.netcoreapp.cs | 180 ---------------- .../System.Drawing.Primitives/tests/SizeFTests.cs | 83 +++++++- .../tests/SizeFTests.netcoreapp.cs | 93 --------- .../System.Drawing.Primitives/tests/SizeTests.cs | 181 ++++++++++++++++- .../tests/SizeTests.netcoreapp.cs | 191 ----------------- .../tests/System.Drawing.Primitives.Tests.csproj | 5 - ...{ISOWeekTests.netcoreapp.cs => ISOWeekTests.cs} | 0 .../System.Globalization.Calendars.Tests.csproj | 4 +- .../tests/System.Linq.Queryable.Tests.csproj | 9 +- .../System.Linq.Queryable/tests/ZipTests.cs | 44 +++- .../tests/ZipTests.netcoreapp.cs | 53 ----- src/libraries/System.Linq/tests/SelectManyTests.cs | 43 +++- .../tests/SelectManyTests.netcoreapp.cs | 53 ----- .../System.Linq/tests/System.Linq.Tests.csproj | 2 - src/libraries/System.Linq/tests/ZipTests.cs | 216 +++++++++++++++++++- .../System.Linq/tests/ZipTests.netcoreapp.cs | 226 --------------------- ...erTests.netcoreapp.cs => RealFormatterTests.cs} | 0 ...arserTests.netcoreapp.cs => RealParserTests.cs} | 0 .../System.Memory/tests/System.Memory.Tests.csproj | 4 +- .../tests/KeyedCollection/TestMethods.cs | 51 ++++- .../KeyedCollection/TestMethods.netcoreapp.cs | 63 ------ .../tests/System.ObjectModel.Tests.csproj | 6 +- .../ObjectModel/KeyedCollectionTests.cs | 83 +++++++- .../ObjectModel/KeyedCollectionTests.netcoreapp.cs | 93 --------- 25 files changed, 866 insertions(+), 985 deletions(-) delete mode 100644 src/libraries/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs delete mode 100644 src/libraries/System.Drawing.Primitives/tests/SizeFTests.netcoreapp.cs delete mode 100644 src/libraries/System.Drawing.Primitives/tests/SizeTests.netcoreapp.cs rename src/libraries/System.Globalization.Calendars/tests/ISOWeek/{ISOWeekTests.netcoreapp.cs => ISOWeekTests.cs} (100%) delete mode 100644 src/libraries/System.Linq.Queryable/tests/ZipTests.netcoreapp.cs delete mode 100644 src/libraries/System.Linq/tests/SelectManyTests.netcoreapp.cs delete mode 100644 src/libraries/System.Linq/tests/ZipTests.netcoreapp.cs rename src/libraries/System.Memory/tests/ParsersAndFormatters/Formatter/{RealFormatterTests.netcoreapp.cs => RealFormatterTests.cs} (100%) rename src/libraries/System.Memory/tests/ParsersAndFormatters/Parser/{RealParserTests.netcoreapp.cs => RealParserTests.cs} (100%) delete mode 100644 src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.netcoreapp.cs delete mode 100644 src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.netcoreapp.cs diff --git a/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs b/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs index ab7a1a3..5206c51 100644 --- a/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs +++ b/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs @@ -10,7 +10,7 @@ using Xunit; namespace System.Drawing.Primitives.Tests { - public partial class ColorTests + public class ColorTests { public static bool SupportsReadingUpdatedSystemColors => PlatformDetection.IsWindows && !PlatformDetection.IsInAppContainer && PlatformDetection.IsNotWindowsNanoServer; @@ -520,6 +520,172 @@ namespace System.Drawing.Primitives.Tests } } + [Theory, MemberData(nameof(NamedArgbValues))] + public void FromKnownColor(string name, int alpha, int red, int green, int blue) + { + Color color = Color.FromKnownColor(Enum.Parse(name)); + Assert.Equal(alpha, color.A); + Assert.Equal(red, color.R); + Assert.Equal(green, color.G); + Assert.Equal(blue, color.B); + } + + [Theory] + [InlineData((KnownColor)(-1))] + [InlineData((KnownColor)0)] + [InlineData(KnownColor.MenuHighlight + 1)] + public void FromOutOfRangeKnownColor(KnownColor known) + { + Color color = Color.FromKnownColor(known); + Assert.Equal(0, color.A); + Assert.Equal(0, color.R); + Assert.Equal(0, color.G); + Assert.Equal(0, color.B); + } + + [Theory, MemberData(nameof(AllKnownColors))] + public void ToKnownColor(KnownColor known) => Assert.Equal(known, Color.FromKnownColor(known).ToKnownColor()); + + [Theory, MemberData(nameof(AllKnownColors))] + public void ToKnownColorMatchesButIsNotKnown(KnownColor known) + { + Color color = Color.FromKnownColor(known); + Color match = Color.FromArgb(color.A, color.R, color.G, color.B); + Assert.Equal((KnownColor)0, match.ToKnownColor()); + } + + [Theory] + [InlineData((KnownColor)(-1))] + [InlineData((KnownColor)0)] + [InlineData(KnownColor.MenuHighlight + 1)] + public void FromOutOfRangeKnownColorToKnownColor(KnownColor known) + { + Color color = Color.FromKnownColor(known); + Assert.Equal((KnownColor)0, color.ToKnownColor()); + } + + [Fact] + public void IsSystemColor() + { + Assert.True(Color.FromName("ActiveBorder").IsSystemColor); + Assert.True(Color.FromName("WindowText").IsSystemColor); + Assert.False(Color.FromName("AliceBlue").IsSystemColor); + } + + [Theory, MemberData(nameof(SystemColors))] + public void IsSystemColorTrue(KnownColor known) => Assert.True(Color.FromKnownColor(known).IsSystemColor); + + [Theory, MemberData(nameof(NonSystemColors))] + public void IsSystemColorFalse(KnownColor known) => Assert.False(Color.FromKnownColor(known).IsSystemColor); + + [Theory, MemberData(nameof(SystemColors))] + public void IsSystemColorFalseOnMatching(KnownColor known) + { + Color color = Color.FromKnownColor(known); + Color match = Color.FromArgb(color.A, color.R, color.G, color.B); + Assert.False(match.IsSystemColor); + } + + [Theory] + [InlineData((KnownColor)(-1))] + [InlineData((KnownColor)0)] + [InlineData(KnownColor.MenuHighlight + 1)] + public void IsSystemColorOutOfRangeKnown(KnownColor known) + { + Color color = Color.FromKnownColor(known); + Assert.False(color.IsSystemColor); + } + + [Theory, MemberData(nameof(AllKnownColors))] + public void IsKnownColorTrue(KnownColor known) + { + Assert.True(Color.FromKnownColor(known).IsKnownColor); + } + + [Theory, MemberData(nameof(AllKnownColors))] + public void IsKnownColorMatchFalse(KnownColor known) + { + Color color = Color.FromKnownColor(known); + Color match = Color.FromArgb(color.A, color.R, color.G, color.B); + Assert.False(match.IsKnownColor); + } + + [Theory] + [InlineData((KnownColor)(-1))] + [InlineData((KnownColor)0)] + [InlineData(KnownColor.MenuHighlight + 1)] + public void IsKnownColorOutOfRangeKnown(KnownColor known) + { + Color color = Color.FromKnownColor(known); + Assert.False(color.IsKnownColor); + } + + [Fact] + public void GetHashCodeForUnknownNamed() + { + // NetFX gives all such colors the same hash code. CoreFX makes more effort with them. + Color c1 = Color.FromName("SomeUnknownColorName"); + Color c2 = Color.FromName("AnotherUnknownColorName"); + Assert.NotEqual(c2.GetHashCode(), c1.GetHashCode()); + Assert.Equal(c1.GetHashCode(), c1.GetHashCode()); + } + + public static readonly IEnumerable AllKnownColors = Enum.GetValues(typeof(KnownColor)).Cast() + .Where(kc => kc != 0) + .Select(kc => new object[] { kc }) + .ToArray(); + + public static readonly IEnumerable SystemColors = + new[] + { + KnownColor.ActiveBorder, KnownColor.ActiveCaption, KnownColor.ActiveCaptionText, + KnownColor.AppWorkspace, KnownColor.Control, KnownColor.ControlDark, KnownColor.ControlDarkDark, + KnownColor.ControlLight, KnownColor.ControlLightLight, KnownColor.ControlText, KnownColor.Desktop, + KnownColor.GrayText, KnownColor.Highlight, KnownColor.HighlightText, KnownColor.HotTrack, + KnownColor.InactiveBorder, KnownColor.InactiveCaption, KnownColor.InactiveCaptionText, KnownColor.Info, + KnownColor.InfoText, KnownColor.Menu, KnownColor.MenuText, KnownColor.ScrollBar, KnownColor.Window, + KnownColor.WindowFrame, KnownColor.WindowText, KnownColor.ButtonFace, KnownColor.ButtonHighlight, + KnownColor.ButtonShadow, KnownColor.GradientActiveCaption, KnownColor.GradientInactiveCaption, + KnownColor.MenuBar, KnownColor.MenuHighlight + }.Select(kc => new object[] { kc }).ToArray(); + + public static readonly IEnumerable NonSystemColors = + new[] + { + KnownColor.Transparent, KnownColor.AliceBlue, KnownColor.AntiqueWhite, KnownColor.Aqua, + KnownColor.Aquamarine, KnownColor.Azure, KnownColor.Beige, KnownColor.Bisque, KnownColor.Black, + KnownColor.BlanchedAlmond, KnownColor.Blue, KnownColor.BlueViolet, KnownColor.Brown, + KnownColor.BurlyWood, KnownColor.CadetBlue, KnownColor.Chartreuse, KnownColor.Chocolate, + KnownColor.Coral, KnownColor.CornflowerBlue, KnownColor.Cornsilk, KnownColor.Crimson, KnownColor.Cyan, + KnownColor.DarkBlue, KnownColor.DarkCyan, KnownColor.DarkGoldenrod, KnownColor.DarkGray, + KnownColor.DarkGreen, KnownColor.DarkKhaki, KnownColor.DarkMagenta, KnownColor.DarkOliveGreen, + KnownColor.DarkOrange, KnownColor.DarkOrchid, KnownColor.DarkRed, KnownColor.DarkSalmon, + KnownColor.DarkSeaGreen, KnownColor.DarkSlateBlue, KnownColor.DarkSlateGray, KnownColor.DarkTurquoise, + KnownColor.DarkViolet, KnownColor.DeepPink, KnownColor.DeepSkyBlue, KnownColor.DimGray, + KnownColor.DodgerBlue, KnownColor.Firebrick, KnownColor.FloralWhite, KnownColor.ForestGreen, + KnownColor.Fuchsia, KnownColor.Gainsboro, KnownColor.GhostWhite, KnownColor.Gold, KnownColor.Goldenrod, + KnownColor.Gray, KnownColor.Green, KnownColor.GreenYellow, KnownColor.Honeydew, KnownColor.HotPink, + KnownColor.IndianRed, KnownColor.Indigo, KnownColor.Ivory, KnownColor.Khaki, KnownColor.Lavender, + KnownColor.LavenderBlush, KnownColor.LawnGreen, KnownColor.LemonChiffon, KnownColor.LightBlue, + KnownColor.LightCoral, KnownColor.LightCyan, KnownColor.LightGoldenrodYellow, KnownColor.LightGray, + KnownColor.LightGreen, KnownColor.LightPink, KnownColor.LightSalmon, KnownColor.LightSeaGreen, + KnownColor.LightSkyBlue, KnownColor.LightSlateGray, KnownColor.LightSteelBlue, KnownColor.LightYellow, + KnownColor.Lime, KnownColor.LimeGreen, KnownColor.Linen, KnownColor.Magenta, KnownColor.Maroon, + KnownColor.MediumAquamarine, KnownColor.MediumBlue, KnownColor.MediumOrchid, KnownColor.MediumPurple, + KnownColor.MediumSeaGreen, KnownColor.MediumSlateBlue, KnownColor.MediumSpringGreen, + KnownColor.MediumTurquoise, KnownColor.MediumVioletRed, KnownColor.MidnightBlue, KnownColor.MintCream, + KnownColor.MistyRose, KnownColor.Moccasin, KnownColor.NavajoWhite, KnownColor.Navy, KnownColor.OldLace, + KnownColor.Olive, KnownColor.OliveDrab, KnownColor.Orange, KnownColor.OrangeRed, KnownColor.Orchid, + KnownColor.PaleGoldenrod, KnownColor.PaleGreen, KnownColor.PaleTurquoise, KnownColor.PaleVioletRed, + KnownColor.PapayaWhip, KnownColor.PeachPuff, KnownColor.Peru, KnownColor.Pink, KnownColor.Plum, + KnownColor.PowderBlue, KnownColor.Purple, KnownColor.Red, KnownColor.RosyBrown, KnownColor.RoyalBlue, + KnownColor.SaddleBrown, KnownColor.Salmon, KnownColor.SandyBrown, KnownColor.SeaGreen, + KnownColor.SeaShell, KnownColor.Sienna, KnownColor.Silver, KnownColor.SkyBlue, KnownColor.SlateBlue, + KnownColor.SlateGray, KnownColor.Snow, KnownColor.SpringGreen, KnownColor.SteelBlue, KnownColor.Tan, + KnownColor.Teal, KnownColor.Thistle, KnownColor.Tomato, KnownColor.Turquoise, KnownColor.Violet, + KnownColor.Wheat, KnownColor.White, KnownColor.WhiteSmoke, KnownColor.Yellow, KnownColor.YellowGreen + }.Select(kc => new object[] { kc }).ToArray(); + [DllImport("user32.dll", SetLastError = true)] private static extern int SetSysColors(int cElements, int[] lpaElements, int[] lpaRgbValues); diff --git a/src/libraries/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs b/src/libraries/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs deleted file mode 100644 index bc40870..0000000 --- a/src/libraries/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs +++ /dev/null @@ -1,180 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using Xunit; - -namespace System.Drawing.Primitives.Tests -{ - public partial class ColorTests - { - public static readonly IEnumerable AllKnownColors = Enum.GetValues(typeof(KnownColor)).Cast() - .Where(kc => kc != 0) - .Select(kc => new object[] { kc }) - .ToArray(); - - public static readonly IEnumerable SystemColors = - new[] - { - KnownColor.ActiveBorder, KnownColor.ActiveCaption, KnownColor.ActiveCaptionText, - KnownColor.AppWorkspace, KnownColor.Control, KnownColor.ControlDark, KnownColor.ControlDarkDark, - KnownColor.ControlLight, KnownColor.ControlLightLight, KnownColor.ControlText, KnownColor.Desktop, - KnownColor.GrayText, KnownColor.Highlight, KnownColor.HighlightText, KnownColor.HotTrack, - KnownColor.InactiveBorder, KnownColor.InactiveCaption, KnownColor.InactiveCaptionText, KnownColor.Info, - KnownColor.InfoText, KnownColor.Menu, KnownColor.MenuText, KnownColor.ScrollBar, KnownColor.Window, - KnownColor.WindowFrame, KnownColor.WindowText, KnownColor.ButtonFace, KnownColor.ButtonHighlight, - KnownColor.ButtonShadow, KnownColor.GradientActiveCaption, KnownColor.GradientInactiveCaption, - KnownColor.MenuBar, KnownColor.MenuHighlight - }.Select(kc => new object[] { kc }).ToArray(); - - public static readonly IEnumerable NonSystemColors = - new[] - { - KnownColor.Transparent, KnownColor.AliceBlue, KnownColor.AntiqueWhite, KnownColor.Aqua, - KnownColor.Aquamarine, KnownColor.Azure, KnownColor.Beige, KnownColor.Bisque, KnownColor.Black, - KnownColor.BlanchedAlmond, KnownColor.Blue, KnownColor.BlueViolet, KnownColor.Brown, - KnownColor.BurlyWood, KnownColor.CadetBlue, KnownColor.Chartreuse, KnownColor.Chocolate, - KnownColor.Coral, KnownColor.CornflowerBlue, KnownColor.Cornsilk, KnownColor.Crimson, KnownColor.Cyan, - KnownColor.DarkBlue, KnownColor.DarkCyan, KnownColor.DarkGoldenrod, KnownColor.DarkGray, - KnownColor.DarkGreen, KnownColor.DarkKhaki, KnownColor.DarkMagenta, KnownColor.DarkOliveGreen, - KnownColor.DarkOrange, KnownColor.DarkOrchid, KnownColor.DarkRed, KnownColor.DarkSalmon, - KnownColor.DarkSeaGreen, KnownColor.DarkSlateBlue, KnownColor.DarkSlateGray, KnownColor.DarkTurquoise, - KnownColor.DarkViolet, KnownColor.DeepPink, KnownColor.DeepSkyBlue, KnownColor.DimGray, - KnownColor.DodgerBlue, KnownColor.Firebrick, KnownColor.FloralWhite, KnownColor.ForestGreen, - KnownColor.Fuchsia, KnownColor.Gainsboro, KnownColor.GhostWhite, KnownColor.Gold, KnownColor.Goldenrod, - KnownColor.Gray, KnownColor.Green, KnownColor.GreenYellow, KnownColor.Honeydew, KnownColor.HotPink, - KnownColor.IndianRed, KnownColor.Indigo, KnownColor.Ivory, KnownColor.Khaki, KnownColor.Lavender, - KnownColor.LavenderBlush, KnownColor.LawnGreen, KnownColor.LemonChiffon, KnownColor.LightBlue, - KnownColor.LightCoral, KnownColor.LightCyan, KnownColor.LightGoldenrodYellow, KnownColor.LightGray, - KnownColor.LightGreen, KnownColor.LightPink, KnownColor.LightSalmon, KnownColor.LightSeaGreen, - KnownColor.LightSkyBlue, KnownColor.LightSlateGray, KnownColor.LightSteelBlue, KnownColor.LightYellow, - KnownColor.Lime, KnownColor.LimeGreen, KnownColor.Linen, KnownColor.Magenta, KnownColor.Maroon, - KnownColor.MediumAquamarine, KnownColor.MediumBlue, KnownColor.MediumOrchid, KnownColor.MediumPurple, - KnownColor.MediumSeaGreen, KnownColor.MediumSlateBlue, KnownColor.MediumSpringGreen, - KnownColor.MediumTurquoise, KnownColor.MediumVioletRed, KnownColor.MidnightBlue, KnownColor.MintCream, - KnownColor.MistyRose, KnownColor.Moccasin, KnownColor.NavajoWhite, KnownColor.Navy, KnownColor.OldLace, - KnownColor.Olive, KnownColor.OliveDrab, KnownColor.Orange, KnownColor.OrangeRed, KnownColor.Orchid, - KnownColor.PaleGoldenrod, KnownColor.PaleGreen, KnownColor.PaleTurquoise, KnownColor.PaleVioletRed, - KnownColor.PapayaWhip, KnownColor.PeachPuff, KnownColor.Peru, KnownColor.Pink, KnownColor.Plum, - KnownColor.PowderBlue, KnownColor.Purple, KnownColor.Red, KnownColor.RosyBrown, KnownColor.RoyalBlue, - KnownColor.SaddleBrown, KnownColor.Salmon, KnownColor.SandyBrown, KnownColor.SeaGreen, - KnownColor.SeaShell, KnownColor.Sienna, KnownColor.Silver, KnownColor.SkyBlue, KnownColor.SlateBlue, - KnownColor.SlateGray, KnownColor.Snow, KnownColor.SpringGreen, KnownColor.SteelBlue, KnownColor.Tan, - KnownColor.Teal, KnownColor.Thistle, KnownColor.Tomato, KnownColor.Turquoise, KnownColor.Violet, - KnownColor.Wheat, KnownColor.White, KnownColor.WhiteSmoke, KnownColor.Yellow, KnownColor.YellowGreen - }.Select(kc => new object[] { kc }).ToArray(); - - [Theory, MemberData(nameof(NamedArgbValues))] - public void FromKnownColor(string name, int alpha, int red, int green, int blue) - { - Color color = Color.FromKnownColor(Enum.Parse(name)); - Assert.Equal(alpha, color.A); - Assert.Equal(red, color.R); - Assert.Equal(green, color.G); - Assert.Equal(blue, color.B); - } - - [Theory] - [InlineData((KnownColor)(-1))] - [InlineData((KnownColor)0)] - [InlineData(KnownColor.MenuHighlight + 1)] - public void FromOutOfRangeKnownColor(KnownColor known) - { - Color color = Color.FromKnownColor(known); - Assert.Equal(0, color.A); - Assert.Equal(0, color.R); - Assert.Equal(0, color.G); - Assert.Equal(0, color.B); - } - - [Theory, MemberData(nameof(AllKnownColors))] - public void ToKnownColor(KnownColor known) => Assert.Equal(known, Color.FromKnownColor(known).ToKnownColor()); - - [Theory, MemberData(nameof(AllKnownColors))] - public void ToKnownColorMatchesButIsNotKnown(KnownColor known) - { - Color color = Color.FromKnownColor(known); - Color match = Color.FromArgb(color.A, color.R, color.G, color.B); - Assert.Equal((KnownColor)0, match.ToKnownColor()); - } - - [Theory] - [InlineData((KnownColor)(-1))] - [InlineData((KnownColor)0)] - [InlineData(KnownColor.MenuHighlight + 1)] - public void FromOutOfRangeKnownColorToKnownColor(KnownColor known) - { - Color color = Color.FromKnownColor(known); - Assert.Equal((KnownColor)0, color.ToKnownColor()); - } - - [Fact] - public void IsSystemColor() - { - Assert.True(Color.FromName("ActiveBorder").IsSystemColor); - Assert.True(Color.FromName("WindowText").IsSystemColor); - Assert.False(Color.FromName("AliceBlue").IsSystemColor); - } - - [Theory, MemberData(nameof(SystemColors))] - public void IsSystemColorTrue(KnownColor known) => Assert.True(Color.FromKnownColor(known).IsSystemColor); - - [Theory, MemberData(nameof(NonSystemColors))] - public void IsSystemColorFalse(KnownColor known) => Assert.False(Color.FromKnownColor(known).IsSystemColor); - - [Theory, MemberData(nameof(SystemColors))] - public void IsSystemColorFalseOnMatching(KnownColor known) - { - Color color = Color.FromKnownColor(known); - Color match = Color.FromArgb(color.A, color.R, color.G, color.B); - Assert.False(match.IsSystemColor); - } - - [Theory] - [InlineData((KnownColor)(-1))] - [InlineData((KnownColor)0)] - [InlineData(KnownColor.MenuHighlight + 1)] - public void IsSystemColorOutOfRangeKnown(KnownColor known) - { - Color color = Color.FromKnownColor(known); - Assert.False(color.IsSystemColor); - } - - [Theory, MemberData(nameof(AllKnownColors))] - public void IsKnownColorTrue(KnownColor known) - { - Assert.True(Color.FromKnownColor(known).IsKnownColor); - } - - [Theory, MemberData(nameof(AllKnownColors))] - public void IsKnownColorMatchFalse(KnownColor known) - { - Color color = Color.FromKnownColor(known); - Color match = Color.FromArgb(color.A, color.R, color.G, color.B); - Assert.False(match.IsKnownColor); - } - - [Theory] - [InlineData((KnownColor)(-1))] - [InlineData((KnownColor)0)] - [InlineData(KnownColor.MenuHighlight + 1)] - public void IsKnownColorOutOfRangeKnown(KnownColor known) - { - Color color = Color.FromKnownColor(known); - Assert.False(color.IsKnownColor); - } - - [Fact] - public void GetHashCodeForUnknownNamed() - { - // NetFX gives all such colors the same hash code. CoreFX makes more effort with them. - Color c1 = Color.FromName("SomeUnknownColorName"); - Color c2 = Color.FromName("AnotherUnknownColorName"); - Assert.NotEqual(c2.GetHashCode(), c1.GetHashCode()); - Assert.Equal(c1.GetHashCode(), c1.GetHashCode()); - } - } -} diff --git a/src/libraries/System.Drawing.Primitives/tests/SizeFTests.cs b/src/libraries/System.Drawing.Primitives/tests/SizeFTests.cs index b9cb1c6..e3d4e68 100644 --- a/src/libraries/System.Drawing.Primitives/tests/SizeFTests.cs +++ b/src/libraries/System.Drawing.Primitives/tests/SizeFTests.cs @@ -7,7 +7,7 @@ using Xunit; namespace System.Drawing.PrimitivesTest { - public partial class SizeFTests + public class SizeFTests { [Fact] public void DefaultConstructorTest() @@ -149,5 +149,86 @@ namespace System.Drawing.PrimitivesTest SizeF s = new SizeF(0, 0); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "{{Width={0}, Height={1}}}", s.Width, s.Height), s.ToString()); } + + [Theory] + [InlineData(1000.234f, 0.0f)] + [InlineData(1000.234f, 1.0f)] + [InlineData(1000.234f, 2400.933f)] + [InlineData(1000.234f, float.MaxValue)] + [InlineData(1000.234f, -1.0f)] + [InlineData(1000.234f, -2400.933f)] + [InlineData(1000.234f, float.MinValue)] + [InlineData(float.MaxValue, 0.0f)] + [InlineData(float.MaxValue, 1.0f)] + [InlineData(float.MaxValue, 2400.933f)] + [InlineData(float.MaxValue, float.MaxValue)] + [InlineData(float.MaxValue, -1.0f)] + [InlineData(float.MaxValue, -2400.933f)] + [InlineData(float.MaxValue, float.MinValue)] + [InlineData(float.MinValue, 0.0f)] + [InlineData(float.MinValue, 1.0f)] + [InlineData(float.MinValue, 2400.933f)] + [InlineData(float.MinValue, float.MaxValue)] + [InlineData(float.MinValue, -1.0f)] + [InlineData(float.MinValue, -2400.933f)] + [InlineData(float.MinValue, float.MinValue)] + public void MultiplicationTest(float dimension, float multiplier) + { + SizeF sz1 = new SizeF(dimension, dimension); + SizeF mulExpected; + + mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); + + Assert.Equal(mulExpected, sz1 * multiplier); + Assert.Equal(mulExpected, multiplier * sz1); + } + + [Theory] + [InlineData(1111.1111f, 2222.2222f, 3333.3333f)] + public void MultiplicationTestWidthHeightMultiplier(float width, float height, float multiplier) + { + SizeF sz1 = new SizeF(width, height); + SizeF mulExpected; + + mulExpected = new SizeF(width * multiplier, height * multiplier); + + Assert.Equal(mulExpected, sz1 * multiplier); + Assert.Equal(mulExpected, multiplier * sz1); + } + + [Theory] + [InlineData(0.0f, 1.0f)] + [InlineData(1.0f, 1.0f)] + [InlineData(-1.0f, 1.0f)] + [InlineData(1.0f, -1.0f)] + [InlineData(-1.0f, -1.0f)] + [InlineData(float.MaxValue, float.MaxValue)] + [InlineData(float.MaxValue, float.MinValue)] + [InlineData(float.MinValue, float.MaxValue)] + [InlineData(float.MinValue, float.MinValue)] + [InlineData(float.MaxValue, 1.0f)] + [InlineData(float.MinValue, 1.0f)] + [InlineData(float.MaxValue, -1.0f)] + [InlineData(float.MinValue, -1.0f)] + [InlineData(float.MinValue, 0.0f)] + [InlineData(1.0f, float.MinValue)] + [InlineData(1.0f, float.MaxValue)] + [InlineData(-1.0f, float.MinValue)] + [InlineData(-1.0f, float.MaxValue)] + public void DivideTestSizeFloat(float dimension, float divisor) + { + SizeF size = new SizeF(dimension, dimension); + SizeF expected = new SizeF(dimension / divisor, dimension / divisor); + Assert.Equal(expected, size / divisor); + } + + [Theory] + [InlineData(-111.111f, 222.222f, 333.333f)] + public void DivideTestSizeFloatWidthHeightDivisor(float width, float height, float divisor) + { + SizeF size = new SizeF(width, height); + SizeF expected = new SizeF(width / divisor, height / divisor); + Assert.Equal(expected, size / divisor); + } } } diff --git a/src/libraries/System.Drawing.Primitives/tests/SizeFTests.netcoreapp.cs b/src/libraries/System.Drawing.Primitives/tests/SizeFTests.netcoreapp.cs deleted file mode 100644 index f6a4209..0000000 --- a/src/libraries/System.Drawing.Primitives/tests/SizeFTests.netcoreapp.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using Xunit; - -namespace System.Drawing.PrimitivesTest -{ - public partial class SizeFTests - { - [Theory] - [InlineData(1000.234f, 0.0f)] - [InlineData(1000.234f, 1.0f)] - [InlineData(1000.234f, 2400.933f)] - [InlineData(1000.234f, float.MaxValue)] - [InlineData(1000.234f, -1.0f)] - [InlineData(1000.234f, -2400.933f)] - [InlineData(1000.234f, float.MinValue)] - [InlineData(float.MaxValue, 0.0f)] - [InlineData(float.MaxValue, 1.0f)] - [InlineData(float.MaxValue, 2400.933f)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(float.MaxValue, -1.0f)] - [InlineData(float.MaxValue, -2400.933f)] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, 0.0f)] - [InlineData(float.MinValue, 1.0f)] - [InlineData(float.MinValue, 2400.933f)] - [InlineData(float.MinValue, float.MaxValue)] - [InlineData(float.MinValue, -1.0f)] - [InlineData(float.MinValue, -2400.933f)] - [InlineData(float.MinValue, float.MinValue)] - public void MultiplicationTest(float dimension, float multiplier) - { - SizeF sz1 = new SizeF(dimension, dimension); - SizeF mulExpected; - - mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); - - Assert.Equal(mulExpected, sz1 * multiplier); - Assert.Equal(mulExpected, multiplier * sz1); - } - - [Theory] - [InlineData(1111.1111f, 2222.2222f, 3333.3333f)] - public void MultiplicationTestWidthHeightMultiplier(float width, float height, float multiplier) - { - SizeF sz1 = new SizeF(width, height); - SizeF mulExpected; - - mulExpected = new SizeF(width * multiplier, height * multiplier); - - Assert.Equal(mulExpected, sz1 * multiplier); - Assert.Equal(mulExpected, multiplier * sz1); - } - - [Theory] - [InlineData(0.0f, 1.0f)] - [InlineData(1.0f, 1.0f)] - [InlineData(-1.0f, 1.0f)] - [InlineData(1.0f, -1.0f)] - [InlineData(-1.0f, -1.0f)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MaxValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, 1.0f)] - [InlineData(float.MinValue, 1.0f)] - [InlineData(float.MaxValue, -1.0f)] - [InlineData(float.MinValue, -1.0f)] - [InlineData(float.MinValue, 0.0f)] - [InlineData(1.0f, float.MinValue)] - [InlineData(1.0f, float.MaxValue)] - [InlineData(-1.0f, float.MinValue)] - [InlineData(-1.0f, float.MaxValue)] - public void DivideTestSizeFloat(float dimension, float divisor) - { - SizeF size = new SizeF(dimension, dimension); - SizeF expected = new SizeF(dimension / divisor, dimension / divisor); - Assert.Equal(expected, size / divisor); - } - - [Theory] - [InlineData(-111.111f, 222.222f, 333.333f)] - public void DivideTestSizeFloatWidthHeightDivisor(float width, float height, float divisor) - { - SizeF size = new SizeF(width, height); - SizeF expected = new SizeF(width / divisor, height / divisor); - Assert.Equal(expected, size / divisor); - } - } -} diff --git a/src/libraries/System.Drawing.Primitives/tests/SizeTests.cs b/src/libraries/System.Drawing.Primitives/tests/SizeTests.cs index 962e602..dff0327 100644 --- a/src/libraries/System.Drawing.Primitives/tests/SizeTests.cs +++ b/src/libraries/System.Drawing.Primitives/tests/SizeTests.cs @@ -7,7 +7,7 @@ using Xunit; namespace System.Drawing.PrimitivesTests { - public partial class SizeTests + public class SizeTests { [Fact] public void DefaultConstructorTest() @@ -180,5 +180,184 @@ namespace System.Drawing.PrimitivesTests Size sz = new Size(0, 0); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "{{Width={0}, Height={1}}}", sz.Width, sz.Height), sz.ToString()); } + + [Theory] + [InlineData(1000, 0)] + [InlineData(1000, 1)] + [InlineData(1000, 2400)] + [InlineData(1000, int.MaxValue)] + [InlineData(1000, -1)] + [InlineData(1000, -2400)] + [InlineData(1000, int.MinValue)] + [InlineData(int.MaxValue, 0)] + [InlineData(int.MaxValue, 1)] + [InlineData(int.MaxValue, 2400)] + [InlineData(int.MaxValue, int.MaxValue)] + [InlineData(int.MaxValue, -1)] + [InlineData(int.MaxValue, -2400)] + [InlineData(int.MaxValue, int.MinValue)] + [InlineData(int.MinValue, 0)] + [InlineData(int.MinValue, 1)] + [InlineData(int.MinValue, 2400)] + [InlineData(int.MinValue, int.MaxValue)] + [InlineData(int.MinValue, -1)] + [InlineData(int.MinValue, -2400)] + [InlineData(int.MinValue, int.MinValue)] + public void MultiplicationTestSizeInt(int dimension, int multiplier) + { + Size sz1 = new Size(dimension, dimension); + Size mulExpected; + + unchecked + { + mulExpected = new Size(dimension * multiplier, dimension * multiplier); + } + + Assert.Equal(mulExpected, sz1 * multiplier); + Assert.Equal(mulExpected, multiplier * sz1); + } + + [Theory] + [InlineData(1000, 2000, 3000)] + public void MultiplicationTestSizeIntWidthHeightMultiplier(int width, int height, int multiplier) + { + Size sz1 = new Size(width, height); + Size mulExpected; + + unchecked + { + mulExpected = new Size(width * multiplier, height * multiplier); + } + + Assert.Equal(mulExpected, sz1 * multiplier); + Assert.Equal(mulExpected, multiplier * sz1); + } + + + [Theory] + [InlineData(1000, 0.0f)] + [InlineData(1000, 1.0f)] + [InlineData(1000, 2400.933f)] + [InlineData(1000, float.MaxValue)] + [InlineData(1000, -1.0f)] + [InlineData(1000, -2400.933f)] + [InlineData(1000, float.MinValue)] + [InlineData(int.MaxValue, 0.0f)] + [InlineData(int.MaxValue, 1.0f)] + [InlineData(int.MaxValue, 2400.933f)] + [InlineData(int.MaxValue, float.MaxValue)] + [InlineData(int.MaxValue, -1.0f)] + [InlineData(int.MaxValue, -2400.933f)] + [InlineData(int.MaxValue, float.MinValue)] + [InlineData(int.MinValue, 0.0f)] + [InlineData(int.MinValue, 1.0f)] + [InlineData(int.MinValue, 2400.933f)] + [InlineData(int.MinValue, float.MaxValue)] + [InlineData(int.MinValue, -1.0f)] + [InlineData(int.MinValue, -2400.933f)] + [InlineData(int.MinValue, float.MinValue)] + public void MultiplicationTestSizeFloat(int dimension, float multiplier) + { + Size sz1 = new Size(dimension, dimension); + SizeF mulExpected; + + mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); + + Assert.Equal(mulExpected, sz1 * multiplier); + Assert.Equal(mulExpected, multiplier * sz1); + } + + [Theory] + [InlineData(1000, 2000, 30.33f)] + public void MultiplicationTestSizeFloatWidthHeightMultiplier(int width, int height, float multiplier) + { + Size sz1 = new Size(width, height); + SizeF mulExpected; + + mulExpected = new SizeF(width * multiplier, height * multiplier); + + Assert.Equal(mulExpected, sz1 * multiplier); + Assert.Equal(mulExpected, multiplier * sz1); + } + + + [Fact] + public void DivideByZeroChecks() + { + Size size = new Size(100, 100); + Assert.Throws(() => size / 0); + + SizeF expectedSizeF = new SizeF(float.PositiveInfinity, float.PositiveInfinity); + Assert.Equal(expectedSizeF, size / 0.0f); + } + + [Theory] + [InlineData(0, 1)] + [InlineData(1, 1)] + [InlineData(-1, 1)] + [InlineData(1, -1)] + [InlineData(-1, -1)] + [InlineData(int.MaxValue, int.MaxValue)] + [InlineData(int.MaxValue, int.MinValue)] + [InlineData(int.MinValue, int.MaxValue)] + [InlineData(int.MinValue, int.MinValue)] + [InlineData(int.MaxValue, 1)] + [InlineData(int.MinValue, 1)] + [InlineData(int.MaxValue, -1)] + public void DivideTestSizeInt(int dimension, int divisor) + { + Size size = new Size(dimension, dimension); + Size expected; + + expected = new Size(dimension / divisor, dimension / divisor); + + Assert.Equal(expected, size / divisor); + } + + [Theory] + [InlineData(1111, 2222, 3333)] + public void DivideTestSizeIntWidthHeightDivisor(int width, int height, int divisor) + { + Size size = new Size(width, height); + Size expected; + + expected = new Size(width / divisor, height / divisor); + + Assert.Equal(expected, size / divisor); + } + + [Theory] + [InlineData(0, 1.0f)] + [InlineData(1, 1.0f)] + [InlineData(-1, 1.0f)] + [InlineData(1, -1.0f)] + [InlineData(-1, -1.0f)] + [InlineData(int.MaxValue, float.MaxValue)] + [InlineData(int.MaxValue, float.MinValue)] + [InlineData(int.MinValue, float.MaxValue)] + [InlineData(int.MinValue, float.MinValue)] + [InlineData(int.MaxValue, 1.0f)] + [InlineData(int.MinValue, 1.0f)] + [InlineData(int.MaxValue, -1.0f)] + [InlineData(int.MinValue, -1.0f)] + public void DivideTestSizeFloat(int dimension, float divisor) + { + SizeF size = new SizeF(dimension, dimension); + SizeF expected; + + expected = new SizeF(dimension / divisor, dimension / divisor); + Assert.Equal(expected, size / divisor); + } + + [Theory] + [InlineData(1111, 2222, -333.33f)] + public void DivideTestSizeFloatWidthHeightDivisor(int width, int height, float divisor) + { + SizeF size = new SizeF(width, height); + SizeF expected; + + expected = new SizeF(width / divisor, height / divisor); + Assert.Equal(expected, size / divisor); + } } } diff --git a/src/libraries/System.Drawing.Primitives/tests/SizeTests.netcoreapp.cs b/src/libraries/System.Drawing.Primitives/tests/SizeTests.netcoreapp.cs deleted file mode 100644 index ee90a09..0000000 --- a/src/libraries/System.Drawing.Primitives/tests/SizeTests.netcoreapp.cs +++ /dev/null @@ -1,191 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using Xunit; - -namespace System.Drawing.PrimitivesTests -{ - public partial class SizeTests - { - [Theory] - [InlineData(1000, 0)] - [InlineData(1000, 1)] - [InlineData(1000, 2400)] - [InlineData(1000, int.MaxValue)] - [InlineData(1000, -1)] - [InlineData(1000, -2400)] - [InlineData(1000, int.MinValue)] - [InlineData(int.MaxValue, 0)] - [InlineData(int.MaxValue, 1)] - [InlineData(int.MaxValue, 2400)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(int.MaxValue, -1)] - [InlineData(int.MaxValue, -2400)] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, 0)] - [InlineData(int.MinValue, 1)] - [InlineData(int.MinValue, 2400)] - [InlineData(int.MinValue, int.MaxValue)] - [InlineData(int.MinValue, -1)] - [InlineData(int.MinValue, -2400)] - [InlineData(int.MinValue, int.MinValue)] - public void MultiplicationTestSizeInt(int dimension, int multiplier) - { - Size sz1 = new Size(dimension, dimension); - Size mulExpected; - - unchecked - { - mulExpected = new Size(dimension * multiplier, dimension * multiplier); - } - - Assert.Equal(mulExpected, sz1 * multiplier); - Assert.Equal(mulExpected, multiplier * sz1); - } - - [Theory] - [InlineData(1000, 2000, 3000)] - public void MultiplicationTestSizeIntWidthHeightMultiplier(int width, int height, int multiplier) - { - Size sz1 = new Size(width, height); - Size mulExpected; - - unchecked - { - mulExpected = new Size(width * multiplier, height * multiplier); - } - - Assert.Equal(mulExpected, sz1 * multiplier); - Assert.Equal(mulExpected, multiplier * sz1); - } - - - [Theory] - [InlineData(1000, 0.0f)] - [InlineData(1000, 1.0f)] - [InlineData(1000, 2400.933f)] - [InlineData(1000, float.MaxValue)] - [InlineData(1000, -1.0f)] - [InlineData(1000, -2400.933f)] - [InlineData(1000, float.MinValue)] - [InlineData(int.MaxValue, 0.0f)] - [InlineData(int.MaxValue, 1.0f)] - [InlineData(int.MaxValue, 2400.933f)] - [InlineData(int.MaxValue, float.MaxValue)] - [InlineData(int.MaxValue, -1.0f)] - [InlineData(int.MaxValue, -2400.933f)] - [InlineData(int.MaxValue, float.MinValue)] - [InlineData(int.MinValue, 0.0f)] - [InlineData(int.MinValue, 1.0f)] - [InlineData(int.MinValue, 2400.933f)] - [InlineData(int.MinValue, float.MaxValue)] - [InlineData(int.MinValue, -1.0f)] - [InlineData(int.MinValue, -2400.933f)] - [InlineData(int.MinValue, float.MinValue)] - public void MultiplicationTestSizeFloat(int dimension, float multiplier) - { - Size sz1 = new Size(dimension, dimension); - SizeF mulExpected; - - mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); - - Assert.Equal(mulExpected, sz1 * multiplier); - Assert.Equal(mulExpected, multiplier * sz1); - } - - [Theory] - [InlineData(1000, 2000, 30.33f)] - public void MultiplicationTestSizeFloatWidthHeightMultiplier(int width, int height, float multiplier) - { - Size sz1 = new Size(width, height); - SizeF mulExpected; - - mulExpected = new SizeF(width * multiplier, height * multiplier); - - Assert.Equal(mulExpected, sz1 * multiplier); - Assert.Equal(mulExpected, multiplier * sz1); - } - - - [Fact] - public void DivideByZeroChecks() - { - Size size = new Size(100, 100); - Assert.Throws(() => size / 0); - - SizeF expectedSizeF = new SizeF(float.PositiveInfinity, float.PositiveInfinity); - Assert.Equal(expectedSizeF, size / 0.0f); - } - - [Theory] - [InlineData(0, 1)] - [InlineData(1, 1)] - [InlineData(-1, 1)] - [InlineData(1, -1)] - [InlineData(-1, -1)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MaxValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, 1)] - [InlineData(int.MinValue, 1)] - [InlineData(int.MaxValue, -1)] - public void DivideTestSizeInt(int dimension, int divisor) - { - Size size = new Size(dimension, dimension); - Size expected; - - expected = new Size(dimension / divisor, dimension / divisor); - - Assert.Equal(expected, size / divisor); - } - - [Theory] - [InlineData(1111, 2222, 3333)] - public void DivideTestSizeIntWidthHeightDivisor(int width, int height, int divisor) - { - Size size = new Size(width, height); - Size expected; - - expected = new Size(width / divisor, height / divisor); - - Assert.Equal(expected, size / divisor); - } - - [Theory] - [InlineData(0, 1.0f)] - [InlineData(1, 1.0f)] - [InlineData(-1, 1.0f)] - [InlineData(1, -1.0f)] - [InlineData(-1, -1.0f)] - [InlineData(int.MaxValue, float.MaxValue)] - [InlineData(int.MaxValue, float.MinValue)] - [InlineData(int.MinValue, float.MaxValue)] - [InlineData(int.MinValue, float.MinValue)] - [InlineData(int.MaxValue, 1.0f)] - [InlineData(int.MinValue, 1.0f)] - [InlineData(int.MaxValue, -1.0f)] - [InlineData(int.MinValue, -1.0f)] - public void DivideTestSizeFloat(int dimension, float divisor) - { - SizeF size = new SizeF(dimension, dimension); - SizeF expected; - - expected = new SizeF(dimension / divisor, dimension / divisor); - Assert.Equal(expected, size / divisor); - } - - [Theory] - [InlineData(1111, 2222, -333.33f)] - public void DivideTestSizeFloatWidthHeightDivisor(int width, int height, float divisor) - { - SizeF size = new SizeF(width, height); - SizeF expected; - - expected = new SizeF(width / divisor, height / divisor); - Assert.Equal(expected, size / divisor); - } - } -} \ No newline at end of file diff --git a/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj b/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj index ec86f42..0850a88 100644 --- a/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj +++ b/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj @@ -23,9 +23,4 @@ Common\System\Runtime\Serialization\Utils.cs - - - - - diff --git a/src/libraries/System.Globalization.Calendars/tests/ISOWeek/ISOWeekTests.netcoreapp.cs b/src/libraries/System.Globalization.Calendars/tests/ISOWeek/ISOWeekTests.cs similarity index 100% rename from src/libraries/System.Globalization.Calendars/tests/ISOWeek/ISOWeekTests.netcoreapp.cs rename to src/libraries/System.Globalization.Calendars/tests/ISOWeek/ISOWeekTests.cs diff --git a/src/libraries/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj b/src/libraries/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj index c555aa3..e7cf25b 100644 --- a/src/libraries/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj +++ b/src/libraries/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj @@ -40,6 +40,7 @@ + @@ -104,7 +105,4 @@ - - - \ No newline at end of file diff --git a/src/libraries/System.Linq.Queryable/tests/System.Linq.Queryable.Tests.csproj b/src/libraries/System.Linq.Queryable/tests/System.Linq.Queryable.Tests.csproj index cea944c..d918b37 100644 --- a/src/libraries/System.Linq.Queryable/tests/System.Linq.Queryable.Tests.csproj +++ b/src/libraries/System.Linq.Queryable/tests/System.Linq.Queryable.Tests.csproj @@ -2,16 +2,11 @@ netcoreapp-Debug;netcoreapp-Release - - - - - - + @@ -46,9 +41,11 @@ + + diff --git a/src/libraries/System.Linq.Queryable/tests/ZipTests.cs b/src/libraries/System.Linq.Queryable/tests/ZipTests.cs index d320d5f..d10d0ed 100644 --- a/src/libraries/System.Linq.Queryable/tests/ZipTests.cs +++ b/src/libraries/System.Linq.Queryable/tests/ZipTests.cs @@ -7,7 +7,7 @@ using Xunit; namespace System.Linq.Tests { - public partial class ZipTests : EnumerableBasedTests + public class ZipTests : EnumerableBasedTests { [Fact] public void CorrectResults() @@ -49,5 +49,47 @@ namespace System.Linq.Tests var count = (new int[] { 0, 1, 2 }).AsQueryable().Zip((new int[] { 10, 11, 12 }).AsQueryable(), (n1, n2) => n1 + n2).Count(); Assert.Equal(3, count); } + + [Fact] + public void Zip2_CorrectResults() + { + int[] first = new int[] { 1, 2, 3 }; + int[] second = new int[] { 2, 5, 9 }; + var expected = new (int, int)[] { (1, 2), (2, 5), (3, 9) }; + Assert.Equal(expected, first.AsQueryable().Zip(second.AsQueryable())); + } + + [Fact] + public void Zip2_FirstIsNull() + { + IQueryable first = null; + int[] second = new int[] { 2, 5, 9 }; + AssertExtensions.Throws("source1", () => first.Zip(second.AsQueryable())); + } + + [Fact] + public void Zip2_SecondIsNull() + { + int[] first = new int[] { 1, 2, 3 }; + IQueryable second = null; + AssertExtensions.Throws("source2", () => first.AsQueryable().Zip(second)); + } + + [Fact] + public void Zip2() + { + int count = (new int[] { 0, 1, 2 }).AsQueryable().Zip((new int[] { 10, 11, 12 }).AsQueryable()).Count(); + Assert.Equal(3, count); + } + + [Fact] + public void TupleNames() + { + int[] first = new int[] { 1 }; + int[] second = new int[] { 2 }; + var tuple = first.AsQueryable().Zip(second.AsQueryable()).First(); + Assert.Equal(tuple.Item1, tuple.First); + Assert.Equal(tuple.Item2, tuple.Second); + } } } diff --git a/src/libraries/System.Linq.Queryable/tests/ZipTests.netcoreapp.cs b/src/libraries/System.Linq.Queryable/tests/ZipTests.netcoreapp.cs deleted file mode 100644 index 3df559f..0000000 --- a/src/libraries/System.Linq.Queryable/tests/ZipTests.netcoreapp.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Xunit; - -namespace System.Linq.Tests -{ - public partial class ZipTests - { - [Fact] - public void Zip2_CorrectResults() - { - int[] first = new int[] { 1, 2, 3 }; - int[] second = new int[] { 2, 5, 9 }; - var expected = new (int, int)[] { (1, 2), (2, 5), (3, 9) }; - Assert.Equal(expected, first.AsQueryable().Zip(second.AsQueryable())); - } - - [Fact] - public void Zip2_FirstIsNull() - { - IQueryable first = null; - int[] second = new int[] { 2, 5, 9 }; - AssertExtensions.Throws("source1", () => first.Zip(second.AsQueryable())); - } - - [Fact] - public void Zip2_SecondIsNull() - { - int[] first = new int[] { 1, 2, 3 }; - IQueryable second = null; - AssertExtensions.Throws("source2", () => first.AsQueryable().Zip(second)); - } - - [Fact] - public void Zip2() - { - int count = (new int[] { 0, 1, 2 }).AsQueryable().Zip((new int[] { 10, 11, 12 }).AsQueryable()).Count(); - Assert.Equal(3, count); - } - - [Fact] - public void TupleNames() - { - int[] first = new int[] { 1 }; - int[] second = new int[] { 2 }; - var tuple = first.AsQueryable().Zip(second.AsQueryable()).First(); - Assert.Equal(tuple.Item1, tuple.First); - Assert.Equal(tuple.Item2, tuple.Second); - } - } -} diff --git a/src/libraries/System.Linq/tests/SelectManyTests.cs b/src/libraries/System.Linq/tests/SelectManyTests.cs index af732fa..abd6b10 100644 --- a/src/libraries/System.Linq/tests/SelectManyTests.cs +++ b/src/libraries/System.Linq/tests/SelectManyTests.cs @@ -2,14 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Collections; using System.Collections.Generic; using Xunit; namespace System.Linq.Tests { - public partial class SelectManyTests : EnumerableTests + public class SelectManyTests : EnumerableTests { [Fact] public void EmptySource() @@ -492,6 +490,45 @@ namespace System.Linq.Tests } } + [Theory] + [InlineData(10)] + public void EvaluateSelectorOncePerItem(int count) + { + int[] timesCalledMap = new int[count]; + + IEnumerable source = Enumerable.Range(0, 10); + IEnumerable iterator = source.SelectMany(index => + { + timesCalledMap[index]++; + return new[] { index }; + }); + + // Iteration + foreach (int index in iterator) + { + Assert.Equal(Enumerable.Repeat(1, index + 1), timesCalledMap.Take(index + 1)); + Assert.Equal(Enumerable.Repeat(0, timesCalledMap.Length - index - 1), timesCalledMap.Skip(index + 1)); + } + + Array.Clear(timesCalledMap, 0, timesCalledMap.Length); + + // ToArray + iterator.ToArray(); + Assert.Equal(Enumerable.Repeat(1, timesCalledMap.Length), timesCalledMap); + + Array.Clear(timesCalledMap, 0, timesCalledMap.Length); + + // ToList + iterator.ToList(); + Assert.Equal(Enumerable.Repeat(1, timesCalledMap.Length), timesCalledMap); + + Array.Clear(timesCalledMap, 0, timesCalledMap.Length); + + // ToHashSet + iterator.ToHashSet(); + Assert.Equal(Enumerable.Repeat(1, timesCalledMap.Length), timesCalledMap); + } + public static IEnumerable GetToArrayDataSources() { // Marker at the end diff --git a/src/libraries/System.Linq/tests/SelectManyTests.netcoreapp.cs b/src/libraries/System.Linq/tests/SelectManyTests.netcoreapp.cs deleted file mode 100644 index 95e7496..0000000 --- a/src/libraries/System.Linq/tests/SelectManyTests.netcoreapp.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using Xunit; - -namespace System.Linq.Tests -{ - public partial class SelectManyTests : EnumerableTests - { - [Theory] - [InlineData(10)] - public void EvaluateSelectorOncePerItem(int count) - { - int[] timesCalledMap = new int[count]; - - IEnumerable source = Enumerable.Range(0, 10); - IEnumerable iterator = source.SelectMany(index => - { - timesCalledMap[index]++; - return new[] { index }; - }); - - // Iteration - foreach (int index in iterator) - { - Assert.Equal(Enumerable.Repeat(1, index + 1), timesCalledMap.Take(index + 1)); - Assert.Equal(Enumerable.Repeat(0, timesCalledMap.Length - index - 1), timesCalledMap.Skip(index + 1)); - } - - Array.Clear(timesCalledMap, 0, timesCalledMap.Length); - - // ToArray - iterator.ToArray(); - Assert.Equal(Enumerable.Repeat(1, timesCalledMap.Length), timesCalledMap); - - Array.Clear(timesCalledMap, 0, timesCalledMap.Length); - - // ToList - iterator.ToList(); - Assert.Equal(Enumerable.Repeat(1, timesCalledMap.Length), timesCalledMap); - - Array.Clear(timesCalledMap, 0, timesCalledMap.Length); - - // ToHashSet - iterator.ToHashSet(); - Assert.Equal(Enumerable.Repeat(1, timesCalledMap.Length), timesCalledMap); - } - } -} diff --git a/src/libraries/System.Linq/tests/System.Linq.Tests.csproj b/src/libraries/System.Linq/tests/System.Linq.Tests.csproj index 7a51c40..5b3ab11 100644 --- a/src/libraries/System.Linq/tests/System.Linq.Tests.csproj +++ b/src/libraries/System.Linq/tests/System.Linq.Tests.csproj @@ -42,7 +42,6 @@ - @@ -67,7 +66,6 @@ - Common\System\Linq\SkipTakeData.cs diff --git a/src/libraries/System.Linq/tests/ZipTests.cs b/src/libraries/System.Linq/tests/ZipTests.cs index 2aabacf..19222eb 100644 --- a/src/libraries/System.Linq/tests/ZipTests.cs +++ b/src/libraries/System.Linq/tests/ZipTests.cs @@ -7,7 +7,7 @@ using Xunit; namespace System.Linq.Tests { - public partial class ZipTests : EnumerableTests + public class ZipTests : EnumerableTests { [Fact] public void ImplicitTypeParameters() @@ -388,5 +388,219 @@ namespace System.Linq.Tests Assert.Equal(expected, first.RunOnce().Zip(second.RunOnce(), func)); } + + [Fact] + public void Zip2_ImplicitTypeParameters() + { + IEnumerable first = new int[] { 1, 2, 3 }; + IEnumerable second = new int[] { 2, 5, 9 }; + IEnumerable<(int, int)> expected = new (int,int)[] { (1,2), (2,5), (3,9) }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_ExplicitTypeParameters() + { + IEnumerable first = new int[] { 1, 2, 3 }; + IEnumerable second = new int[] { 2, 5, 9 }; + IEnumerable<(int, int)> expected = new (int,int)[] { (1,2), (2,5), (3,9) }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_FirstIsNull() + { + IEnumerable first = null; + IEnumerable second = new int[] { 2, 5, 9 }; + + AssertExtensions.Throws("first", () => first.Zip(second)); + } + + [Fact] + public void Zip2_SecondIsNull() + { + IEnumerable first = new int[] { 1, 2, 3 }; + IEnumerable second = null; + + AssertExtensions.Throws("second", () => first.Zip(second)); + } + + [Fact] + public void Zip2_ExceptionThrownFromFirstsEnumerator() + { + ThrowsOnMatchEnumerable first = new ThrowsOnMatchEnumerable(new int[] { 1, 3, 3 }, 2); + IEnumerable second = new int[] { 2, 4, 6 }; + IEnumerable<(int, int)> expected = new (int,int)[] { (1,2), (3,4), (3,6) }; + + Assert.Equal(expected, first.Zip(second)); + + first = new ThrowsOnMatchEnumerable(new int[] { 1, 2, 3 }, 2); + + IEnumerable<(int, int)> zip = first.Zip(second); + + Assert.Throws(() => zip.ToList()); + } + + [Fact] + public void Zip2_ExceptionThrownFromSecondsEnumerator() + { + ThrowsOnMatchEnumerable second = new ThrowsOnMatchEnumerable(new int[] { 1, 3, 3 }, 2); + IEnumerable first = new int[] { 2, 4, 6 }; + IEnumerable<(int, int)> expected = new (int,int)[] { (2,1), (4,3), (6,3) }; + + Assert.Equal(expected, first.Zip(second)); + + second = new ThrowsOnMatchEnumerable(new int[] { 1, 2, 3 }, 2); + + IEnumerable<(int, int)> zip = first.Zip(second); + + Assert.Throws(() => zip.ToList()); + } + + [Fact] + public void Zip2_FirstAndSecondEmpty() + { + IEnumerable first = new int[] { }; + IEnumerable second = new int[] { }; + IEnumerable<(int, int)> expected = new (int, int)[] { }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_FirstEmptySecondSingle() + { + IEnumerable first = new int[] { }; + IEnumerable second = new int[] { 2 }; + IEnumerable<(int, int)> expected = new (int, int)[] { }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_FirstEmptySecondMany() + { + IEnumerable first = new int[] { }; + IEnumerable second = new int[] { 2, 4, 8 }; + IEnumerable<(int, int)> expected = new (int, int)[] { }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_SecondEmptyFirstSingle() + { + IEnumerable first = new int[] { 1 }; + IEnumerable second = new int[] { }; + IEnumerable<(int, int)> expected = new (int, int)[] { }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_SecondEmptyFirstMany() + { + IEnumerable first = new int[] { 1, 2, 3 }; + IEnumerable second = new int[] { }; + IEnumerable<(int, int)> expected = new (int, int)[] { }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_FirstAndSecondSingle() + { + IEnumerable first = new int[] { 1 }; + IEnumerable second = new int[] { 2 }; + IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2) }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_FirstAndSecondEqualSize() + { + IEnumerable first = new int[] { 1, 2, 3 }; + IEnumerable second = new int[] { 2, 3, 4 }; + IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 3), (3, 4) }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_SecondOneMoreThanFirst() + { + IEnumerable first = new int[] { 1, 2 }; + IEnumerable second = new int[] { 2, 4, 8 }; + IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; + + Assert.Equal(expected, first.Zip(second)); + } + + + [Fact] + public void Zip2_SecondManyMoreThanFirst() + { + IEnumerable first = new int[] { 1, 2 }; + IEnumerable second = new int[] { 2, 4, 8, 16 }; + IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_FirstOneMoreThanSecond() + { + IEnumerable first = new int[] { 1, 2, 3 }; + IEnumerable second = new int[] { 2, 4 }; + IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_FirstManyMoreThanSecond() + { + IEnumerable first = new int[] { 1, 2, 3, 4 }; + IEnumerable second = new int[] { 2, 4 }; + IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; + + Assert.Equal(expected, first.Zip(second)); + } + + [Fact] + public void Zip2_RunOnce() + { + IEnumerable first = new[] { 1, (int?)null, 3 }; + IEnumerable second = new[] { 2, 4, 6, 8 }; + IEnumerable<(int?, int)> expected = new (int?, int)[] { (1, 2), (null, 4), (3, 6) }; + + Assert.Equal(expected, first.RunOnce().Zip(second.RunOnce())); + } + + [Fact] + public void Zip2_NestedTuple() + { + IEnumerable first = new[] { 1, 3, 5 }; + IEnumerable second = new[] { 2, 4, 6 }; + IEnumerable<(int, int)> third = new[] { (1, 2), (3, 4), (5, 6) }; + + Assert.Equal(third, first.Zip(second)); + + IEnumerable fourth = new[] { "one", "two", "three" }; + + IEnumerable<((int, int), string)> final = new[] { ((1, 2), "one"), ((3, 4), "two"), ((5, 6), "three") }; + Assert.Equal(final, third.Zip(fourth)); + } + + [Fact] + public void Zip2_TupleNames() + { + var t = new[] { 1, 2, 3 }.Zip(new[] { 2, 4, 6 }).First(); + Assert.Equal(t.Item1, t.First); + Assert.Equal(t.Item2, t.Second); + } } } diff --git a/src/libraries/System.Linq/tests/ZipTests.netcoreapp.cs b/src/libraries/System.Linq/tests/ZipTests.netcoreapp.cs deleted file mode 100644 index 7cf6cbf..0000000 --- a/src/libraries/System.Linq/tests/ZipTests.netcoreapp.cs +++ /dev/null @@ -1,226 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Xunit; - -namespace System.Linq.Tests -{ - public partial class ZipTests - { - [Fact] - public void Zip2_ImplicitTypeParameters() - { - IEnumerable first = new int[] { 1, 2, 3 }; - IEnumerable second = new int[] { 2, 5, 9 }; - IEnumerable<(int, int)> expected = new (int,int)[] { (1,2), (2,5), (3,9) }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_ExplicitTypeParameters() - { - IEnumerable first = new int[] { 1, 2, 3 }; - IEnumerable second = new int[] { 2, 5, 9 }; - IEnumerable<(int, int)> expected = new (int,int)[] { (1,2), (2,5), (3,9) }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_FirstIsNull() - { - IEnumerable first = null; - IEnumerable second = new int[] { 2, 5, 9 }; - - AssertExtensions.Throws("first", () => first.Zip(second)); - } - - [Fact] - public void Zip2_SecondIsNull() - { - IEnumerable first = new int[] { 1, 2, 3 }; - IEnumerable second = null; - - AssertExtensions.Throws("second", () => first.Zip(second)); - } - - [Fact] - public void Zip2_ExceptionThrownFromFirstsEnumerator() - { - ThrowsOnMatchEnumerable first = new ThrowsOnMatchEnumerable(new int[] { 1, 3, 3 }, 2); - IEnumerable second = new int[] { 2, 4, 6 }; - IEnumerable<(int, int)> expected = new (int,int)[] { (1,2), (3,4), (3,6) }; - - Assert.Equal(expected, first.Zip(second)); - - first = new ThrowsOnMatchEnumerable(new int[] { 1, 2, 3 }, 2); - - IEnumerable<(int, int)> zip = first.Zip(second); - - Assert.Throws(() => zip.ToList()); - } - - [Fact] - public void Zip2_ExceptionThrownFromSecondsEnumerator() - { - ThrowsOnMatchEnumerable second = new ThrowsOnMatchEnumerable(new int[] { 1, 3, 3 }, 2); - IEnumerable first = new int[] { 2, 4, 6 }; - IEnumerable<(int, int)> expected = new (int,int)[] { (2,1), (4,3), (6,3) }; - - Assert.Equal(expected, first.Zip(second)); - - second = new ThrowsOnMatchEnumerable(new int[] { 1, 2, 3 }, 2); - - IEnumerable<(int, int)> zip = first.Zip(second); - - Assert.Throws(() => zip.ToList()); - } - - [Fact] - public void Zip2_FirstAndSecondEmpty() - { - IEnumerable first = new int[] { }; - IEnumerable second = new int[] { }; - IEnumerable<(int, int)> expected = new (int, int)[] { }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_FirstEmptySecondSingle() - { - IEnumerable first = new int[] { }; - IEnumerable second = new int[] { 2 }; - IEnumerable<(int, int)> expected = new (int, int)[] { }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_FirstEmptySecondMany() - { - IEnumerable first = new int[] { }; - IEnumerable second = new int[] { 2, 4, 8 }; - IEnumerable<(int, int)> expected = new (int, int)[] { }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_SecondEmptyFirstSingle() - { - IEnumerable first = new int[] { 1 }; - IEnumerable second = new int[] { }; - IEnumerable<(int, int)> expected = new (int, int)[] { }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_SecondEmptyFirstMany() - { - IEnumerable first = new int[] { 1, 2, 3 }; - IEnumerable second = new int[] { }; - IEnumerable<(int, int)> expected = new (int, int)[] { }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_FirstAndSecondSingle() - { - IEnumerable first = new int[] { 1 }; - IEnumerable second = new int[] { 2 }; - IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2) }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_FirstAndSecondEqualSize() - { - IEnumerable first = new int[] { 1, 2, 3 }; - IEnumerable second = new int[] { 2, 3, 4 }; - IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 3), (3, 4) }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_SecondOneMoreThanFirst() - { - IEnumerable first = new int[] { 1, 2 }; - IEnumerable second = new int[] { 2, 4, 8 }; - IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; - - Assert.Equal(expected, first.Zip(second)); - } - - - [Fact] - public void Zip2_SecondManyMoreThanFirst() - { - IEnumerable first = new int[] { 1, 2 }; - IEnumerable second = new int[] { 2, 4, 8, 16 }; - IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_FirstOneMoreThanSecond() - { - IEnumerable first = new int[] { 1, 2, 3 }; - IEnumerable second = new int[] { 2, 4 }; - IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_FirstManyMoreThanSecond() - { - IEnumerable first = new int[] { 1, 2, 3, 4 }; - IEnumerable second = new int[] { 2, 4 }; - IEnumerable<(int, int)> expected = new (int, int)[] { (1, 2), (2, 4) }; - - Assert.Equal(expected, first.Zip(second)); - } - - [Fact] - public void Zip2_RunOnce() - { - IEnumerable first = new[] { 1, (int?)null, 3 }; - IEnumerable second = new[] { 2, 4, 6, 8 }; - IEnumerable<(int?, int)> expected = new (int?, int)[] { (1, 2), (null, 4), (3, 6) }; - - Assert.Equal(expected, first.RunOnce().Zip(second.RunOnce())); - } - - [Fact] - public void Zip2_NestedTuple() - { - IEnumerable first = new[] { 1, 3, 5 }; - IEnumerable second = new[] { 2, 4, 6 }; - IEnumerable<(int, int)> third = new[] { (1, 2), (3, 4), (5, 6) }; - - Assert.Equal(third, first.Zip(second)); - - IEnumerable fourth = new[] { "one", "two", "three" }; - - IEnumerable<((int, int), string)> final = new[] { ((1, 2), "one"), ((3, 4), "two"), ((5, 6), "three") }; - Assert.Equal(final, third.Zip(fourth)); - } - - [Fact] - public void Zip2_TupleNames() - { - var t = new[] { 1, 2, 3 }.Zip(new[] { 2, 4, 6 }).First(); - Assert.Equal(t.Item1, t.First); - Assert.Equal(t.Item2, t.Second); - } - } -} diff --git a/src/libraries/System.Memory/tests/ParsersAndFormatters/Formatter/RealFormatterTests.netcoreapp.cs b/src/libraries/System.Memory/tests/ParsersAndFormatters/Formatter/RealFormatterTests.cs similarity index 100% rename from src/libraries/System.Memory/tests/ParsersAndFormatters/Formatter/RealFormatterTests.netcoreapp.cs rename to src/libraries/System.Memory/tests/ParsersAndFormatters/Formatter/RealFormatterTests.cs diff --git a/src/libraries/System.Memory/tests/ParsersAndFormatters/Parser/RealParserTests.netcoreapp.cs b/src/libraries/System.Memory/tests/ParsersAndFormatters/Parser/RealParserTests.cs similarity index 100% rename from src/libraries/System.Memory/tests/ParsersAndFormatters/Parser/RealParserTests.netcoreapp.cs rename to src/libraries/System.Memory/tests/ParsersAndFormatters/Parser/RealParserTests.cs diff --git a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj index 368de3a..e0c7784 100644 --- a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj +++ b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj @@ -16,9 +16,9 @@ - + - + diff --git a/src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.cs b/src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.cs index d6e4da2..ca2163c 100644 --- a/src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.cs +++ b/src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.cs @@ -9,7 +9,7 @@ using Xunit; namespace System.Collections.ObjectModel.Tests { - public abstract partial class KeyedCollectionTests + public abstract class KeyedCollectionTests where TValue : IComparable where TKey : IEquatable { private static readonly bool s_keyNullable = default(TKey) @@ -2019,6 +2019,55 @@ namespace System.Collections.ObjectModel.Tests } } } + + [Theory] + [MemberData(nameof(ContainsKeyData))] + public void TryGetValue( + int collectionSize, + Named> + generateKeyedItem) + { + TKey[] keys; + IKeyedItem[] items; + IKeyedItem[] itemsWithKeys; + var collection = + new TestKeyedCollectionOfIKeyedItem(); + collection.AddItems( + generateKeyedItem.Value.Bind( + GenerateValue, + GetKeyForItem), + ki => ki.Key, + collectionSize, + out keys, + out items, + out itemsWithKeys); + IKeyedItem itemNotIn = + generateKeyedItem.Value(GenerateValue, GetKeyForItem); + + TKey keyNotIn = itemNotIn.Key; + if (keyNotIn == null) + { + IKeyedItem item; + AssertExtensions.Throws("key", () => collection.TryGetValue(keyNotIn, out item)); + } + else + { + IKeyedItem item; + Assert.False(collection.TryGetValue(keyNotIn, out item)); + } + foreach (TKey k in keys) + { + IKeyedItem item; + TKey key = k; + if (key == null) + { + AssertExtensions.Throws("key", () => collection.TryGetValue(key, out item)); + continue; + } + Assert.True(collection.TryGetValue(key, out item)); + Assert.Equal(item.Key, key); + } + } } public abstract class IListTestKeyedCollection : diff --git a/src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.netcoreapp.cs b/src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.netcoreapp.cs deleted file mode 100644 index fc67ccf..0000000 --- a/src/libraries/System.ObjectModel/tests/KeyedCollection/TestMethods.netcoreapp.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Linq; -using Tests.Collections; -using Xunit; - -namespace System.Collections.ObjectModel.Tests -{ - public abstract partial class KeyedCollectionTests - { - [Theory] - [MemberData(nameof(ContainsKeyData))] - public void TryGetValue( - int collectionSize, - Named> - generateKeyedItem) - { - TKey[] keys; - IKeyedItem[] items; - IKeyedItem[] itemsWithKeys; - var collection = - new TestKeyedCollectionOfIKeyedItem(); - collection.AddItems( - generateKeyedItem.Value.Bind( - GenerateValue, - GetKeyForItem), - ki => ki.Key, - collectionSize, - out keys, - out items, - out itemsWithKeys); - IKeyedItem itemNotIn = - generateKeyedItem.Value(GenerateValue, GetKeyForItem); - - TKey keyNotIn = itemNotIn.Key; - if (keyNotIn == null) - { - IKeyedItem item; - AssertExtensions.Throws("key", () => collection.TryGetValue(keyNotIn, out item)); - } - else - { - IKeyedItem item; - Assert.False(collection.TryGetValue(keyNotIn, out item)); - } - foreach (TKey k in keys) - { - IKeyedItem item; - TKey key = k; - if (key == null) - { - AssertExtensions.Throws("key", () => collection.TryGetValue(key, out item)); - continue; - } - Assert.True(collection.TryGetValue(key, out item)); - Assert.Equal(item.Key, key); - } - } - } -} diff --git a/src/libraries/System.ObjectModel/tests/System.ObjectModel.Tests.csproj b/src/libraries/System.ObjectModel/tests/System.ObjectModel.Tests.csproj index bb48116..e11d165 100644 --- a/src/libraries/System.ObjectModel/tests/System.ObjectModel.Tests.csproj +++ b/src/libraries/System.ObjectModel/tests/System.ObjectModel.Tests.csproj @@ -32,6 +32,7 @@ + @@ -42,11 +43,6 @@ Common\System\Diagnostics\DebuggerAttributes.cs - - - - - diff --git a/src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.cs b/src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.cs index 6c00dd8..46c1a93 100644 --- a/src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.cs +++ b/src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.cs @@ -8,7 +8,7 @@ using Xunit; namespace System.Collections.ObjectModel.Tests { - public partial class KeyedCollectionTests + public class KeyedCollectionTests { [Fact] public void Ctor_Default() @@ -974,6 +974,87 @@ namespace System.Collections.ObjectModel.Tests AssertExtensions.Throws("index", () => collection.SetItem(index, "first")); } + public static IEnumerable TryGetValue_TestData() + { + yield return new object[] { null, "first_key", true, "first" }; + yield return new object[] { null, "FIRST_KEY", false, null }; + yield return new object[] { null, "NoSuchKey", false, null }; + yield return new object[] { StringComparer.OrdinalIgnoreCase, "first_key", true, "first" }; + yield return new object[] { StringComparer.OrdinalIgnoreCase, "FIRST_KEY", true, "first" }; + yield return new object[] { StringComparer.OrdinalIgnoreCase, "NoSuchKey", false, null }; + } + + [Theory] + [MemberData(nameof(TryGetValue_TestData))] + public void TryGetValue_Invoke_ReturnsExpected(IEqualityComparer comparer, string key, bool expected, string expectedItem) + { + var collection = new StringKeyedCollection(comparer, 3); + collection.GetKeyForItemHandler = i => i + "_key"; + + // Without dictionary. + collection.InsertItem(0, "first"); + Assert.Equal(expected, collection.TryGetValue(key, out string item)); + Assert.Equal(expectedItem, item); + + // With dictionary. + collection.InsertItem(0, "second"); + collection.InsertItem(0, "third"); + collection.InsertItem(0, "fourth"); + Assert.Equal(expected, collection.TryGetValue(key, out item)); + Assert.Equal(expectedItem, item); + } + + [Theory] + [InlineData(3, true, 2)] + [InlineData(4, false, 0)] + public void TryGetValue_NullKeyForItemResult_Success(int dictionaryCreationThreshold, bool expected, int expectedItem) + { + var collection = new StringKeyedCollection(null, dictionaryCreationThreshold); + collection.GetKeyForItemHandler = i => i.ToString(); + collection.Add(1); + collection.Add(2); + collection.Add(3); + collection.Add(4); + + // Don't get even numbers. + collection.GetKeyForItemHandler = i => i % 2 == 0 ? null : i.ToString(); + + // Get null key. + Assert.Equal(expected, collection.TryGetValue("2", out int item)); + Assert.Equal(expectedItem, item); + + // Get non null key. + Assert.True(collection.TryGetValue("1", out item)); + Assert.Equal(1, item); + } + + [Theory] + [InlineData(3, false, 0)] + [InlineData(4, true, 3)] + public void TryGetValue_DifferentKeyForItemResult_Success(int dictionaryCreationThreshold, bool expected, int expectedItem) + { + var collection = new StringKeyedCollection(null, dictionaryCreationThreshold); + collection.GetKeyForItemHandler = i => i.ToString(); + collection.Add(1); + collection.Add(2); + collection.Add(3); + collection.Add(4); + + collection.GetKeyForItemHandler = i => (i * 2).ToString(); + + Assert.Equal(expected, collection.TryGetValue("6", out int item)); + Assert.Equal(expectedItem, item); + } + + [Fact] + public void TryGetValue_NullKey_ThrowsArgumentNullException() + { + var collection = new StringKeyedCollection(); + string item = "item"; + AssertExtensions.Throws("key", () => collection.TryGetValue(null, out item)); + Assert.Equal("item", item); + } + private class StringKeyedCollection : KeyedCollection { public StringKeyedCollection() : base() diff --git a/src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.netcoreapp.cs b/src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.netcoreapp.cs deleted file mode 100644 index 7fd5e98..0000000 --- a/src/libraries/System.ObjectModel/tests/System/Collections/ObjectModel/KeyedCollectionTests.netcoreapp.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Xunit; - -namespace System.Collections.ObjectModel.Tests -{ - public partial class KeyedCollectionTests - { - public static IEnumerable TryGetValue_TestData() - { - yield return new object[] { null, "first_key", true, "first" }; - yield return new object[] { null, "FIRST_KEY", false, null }; - yield return new object[] { null, "NoSuchKey", false, null }; - yield return new object[] { StringComparer.OrdinalIgnoreCase, "first_key", true, "first" }; - yield return new object[] { StringComparer.OrdinalIgnoreCase, "FIRST_KEY", true, "first" }; - yield return new object[] { StringComparer.OrdinalIgnoreCase, "NoSuchKey", false, null }; - } - - [Theory] - [MemberData(nameof(TryGetValue_TestData))] - public void TryGetValue_Invoke_ReturnsExpected(IEqualityComparer comparer, string key, bool expected, string expectedItem) - { - var collection = new StringKeyedCollection(comparer, 3); - collection.GetKeyForItemHandler = i => i + "_key"; - - // Without dictionary. - collection.InsertItem(0, "first"); - Assert.Equal(expected, collection.TryGetValue(key, out string item)); - Assert.Equal(expectedItem, item); - - // With dictionary. - collection.InsertItem(0, "second"); - collection.InsertItem(0, "third"); - collection.InsertItem(0, "fourth"); - Assert.Equal(expected, collection.TryGetValue(key, out item)); - Assert.Equal(expectedItem, item); - } - - [Theory] - [InlineData(3, true, 2)] - [InlineData(4, false, 0)] - public void TryGetValue_NullKeyForItemResult_Success(int dictionaryCreationThreshold, bool expected, int expectedItem) - { - var collection = new StringKeyedCollection(null, dictionaryCreationThreshold); - collection.GetKeyForItemHandler = i => i.ToString(); - collection.Add(1); - collection.Add(2); - collection.Add(3); - collection.Add(4); - - // Don't get even numbers. - collection.GetKeyForItemHandler = i => i % 2 == 0 ? null : i.ToString(); - - // Get null key. - Assert.Equal(expected, collection.TryGetValue("2", out int item)); - Assert.Equal(expectedItem, item); - - // Get non null key. - Assert.True(collection.TryGetValue("1", out item)); - Assert.Equal(1, item); - } - - [Theory] - [InlineData(3, false, 0)] - [InlineData(4, true, 3)] - public void TryGetValue_DifferentKeyForItemResult_Success(int dictionaryCreationThreshold, bool expected, int expectedItem) - { - var collection = new StringKeyedCollection(null, dictionaryCreationThreshold); - collection.GetKeyForItemHandler = i => i.ToString(); - collection.Add(1); - collection.Add(2); - collection.Add(3); - collection.Add(4); - - collection.GetKeyForItemHandler = i => (i * 2).ToString(); - - Assert.Equal(expected, collection.TryGetValue("6", out int item)); - Assert.Equal(expectedItem, item); - } - - [Fact] - public void TryGetValue_NullKey_ThrowsArgumentNullException() - { - var collection = new StringKeyedCollection(); - string item = "item"; - AssertExtensions.Throws("key", () => collection.TryGetValue(null, out item)); - Assert.Equal("item", item); - } - } -} -- 2.7.4