From af32a51e4239991f1a033c23f44e20bfe8fcf68f Mon Sep 17 00:00:00 2001 From: Loni Tra Date: Fri, 22 Nov 2024 02:02:15 -0800 Subject: [PATCH] Start using System.Private.Windows.Core.TestUtilities (#10104) * Add System.Private.Windows.Core.TestUtilities package reference and bump xunit version * Test private field SplashScreen._resourceName using TestAccessor --- eng/Versions.props | 4 +++- .../PresentationCore.Tests/BinaryFormat/ArrayTests.cs | 6 +++--- .../BinaryFormat/BinaryFormatWriterTests.cs | 6 +++--- .../WindowsBase.Tests/System/Windows/SplashScreenTests.cs | 2 ++ .../UnitTests/WindowsBase.Tests/WindowsBase.Tests.csproj | 1 + 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 87d7c4d3efc..0347fa4e88a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -84,7 +84,7 @@ - 2.9.0 + 2.9.2 $(XUnitVersion) $(XUnitVersion) 2.8.1 @@ -99,6 +99,8 @@ 8.0.0-beta.23107.1 8.0.0-beta.23107.1 14.2.0 + + 10.0.0-alpha.1.24571.3 diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/ArrayTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/ArrayTests.cs index 695e7bb9ee8..2b78ddb4893 100644 --- a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/ArrayTests.cs +++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/ArrayTests.cs @@ -1,11 +1,11 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace PresentationCore.Tests.BinaryFormat; public class ArrayTests { - public static TheoryData StringArray_Parse_Data => new() + public static TheoryData StringArray_Parse_Data => new() { new string?[] { "one", "two" }, new string?[] { "yes", "no", null }, @@ -20,7 +20,7 @@ public class ArrayTests new DateTime[] { DateTime.MaxValue } }; - public static IEnumerable Array_TestData => StringArray_Parse_Data.Concat(PrimitiveArray_Parse_Data); + public static IEnumerable Array_TestData => ((IEnumerable)StringArray_Parse_Data).Concat(PrimitiveArray_Parse_Data); public static TheoryData Array_UnsupportedTestData => new() { diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/BinaryFormatWriterTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/BinaryFormatWriterTests.cs index a1f787d4434..26f460aff34 100644 --- a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/BinaryFormatWriterTests.cs +++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationCore.Tests/BinaryFormat/BinaryFormatWriterTests.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; @@ -102,7 +102,7 @@ public void BinaryFormatWriter_TryWriteObject_UnsupportedObjects_RoundTrip(objec } public static IEnumerable TryWriteObject_SupportedObjects_TestData => - HashtableTests.Hashtables_TestData.Concat( + ((IEnumerable)HashtableTests.Hashtables_TestData).Concat( ListTests.PrimitiveLists_TestData).Concat( ListTests.ArrayLists_TestData).Concat( PrimitiveTypeTests.Primitive_Data).Concat( @@ -110,7 +110,7 @@ public void BinaryFormatWriter_TryWriteObject_UnsupportedObjects_RoundTrip(objec ArrayTests.Array_TestData); public static IEnumerable TryWriteObject_UnsupportedObjects_TestData => - HashtableTests.Hashtables_UnsupportedTestData.Concat( + ((IEnumerable)HashtableTests.Hashtables_UnsupportedTestData).Concat( ListTests.Lists_UnsupportedTestData).Concat( ListTests.ArrayLists_UnsupportedTestData).Concat( ArrayTests.Array_UnsupportedTestData); diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/System/Windows/SplashScreenTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/System/Windows/SplashScreenTests.cs index 7f7e1978c02..44dcbb5f669 100644 --- a/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/System/Windows/SplashScreenTests.cs +++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/System/Windows/SplashScreenTests.cs @@ -15,6 +15,8 @@ public void Constructor_NullImageSource_ThrowsArgumentNullException() public void Create() { SplashScreen splash = new(typeof(SplashScreenTests).Assembly, "Needle"); + string resourceName = splash.TestAccessor().Dynamic._resourceName; + resourceName.Should().Be("needle"); splash.Show(autoClose: true); } } diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/WindowsBase.Tests.csproj b/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/WindowsBase.Tests.csproj index 0299b96932f..0ac53164184 100644 --- a/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/WindowsBase.Tests.csproj +++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/WindowsBase.Tests.csproj @@ -12,6 +12,7 @@ +