Skip to content

Commit

Permalink
Start using System.Private.Windows.Core.TestUtilities (#10104)
Browse files Browse the repository at this point in the history
* Add System.Private.Windows.Core.TestUtilities package reference and bump xunit version

* Test private field SplashScreen._resourceName using TestAccessor
  • Loading branch information
lonitra authored Nov 22, 2024
1 parent 7d9f5ae commit af32a51
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</PropertyGroup>
<!-- XUnit-related (not extensions) -->
<PropertyGroup>
<XUnitVersion>2.9.0</XUnitVersion>
<XUnitVersion>2.9.2</XUnitVersion>
<XUnitAssertVersion>$(XUnitVersion)</XUnitAssertVersion>
<XUnitRunnerConsoleVersion>$(XUnitVersion)</XUnitRunnerConsoleVersion>
<XUnitRunnerVisualStudioVersion>2.8.1</XUnitRunnerVisualStudioVersion>
Expand All @@ -99,6 +99,8 @@
<SystemDrawingCommonTestDataVersion>8.0.0-beta.23107.1</SystemDrawingCommonTestDataVersion>
<SystemWindowsExtensionsTestDataVersion>8.0.0-beta.23107.1</SystemWindowsExtensionsTestDataVersion>
<VerifyXunitVersion>14.2.0</VerifyXunitVersion>
<!-- Shared test utilities with WinForms -->
<SystemPrivateWindowsCoreTestUtilitiesVersion>10.0.0-alpha.1.24571.3</SystemPrivateWindowsCoreTestUtilitiesVersion>
</PropertyGroup>
<!-- Code Coverage -->
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string?[]> StringArray_Parse_Data => new()
public static TheoryData<Array> StringArray_Parse_Data => new()
{
new string?[] { "one", "two" },
new string?[] { "yes", "no", null },
Expand All @@ -20,7 +20,7 @@ public class ArrayTests
new DateTime[] { DateTime.MaxValue }
};

public static IEnumerable<object[]> Array_TestData => StringArray_Parse_Data.Concat(PrimitiveArray_Parse_Data);
public static IEnumerable<object[]> Array_TestData => ((IEnumerable<object[]>)StringArray_Parse_Data).Concat(PrimitiveArray_Parse_Data);

public static TheoryData<Array> Array_UnsupportedTestData => new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -102,15 +102,15 @@ public void BinaryFormatWriter_TryWriteObject_UnsupportedObjects_RoundTrip(objec
}

public static IEnumerable<object[]?> TryWriteObject_SupportedObjects_TestData =>
HashtableTests.Hashtables_TestData.Concat(
((IEnumerable<object[]?>)HashtableTests.Hashtables_TestData).Concat(
ListTests.PrimitiveLists_TestData).Concat(
ListTests.ArrayLists_TestData).Concat(
PrimitiveTypeTests.Primitive_Data).Concat(
SystemDrawingTests.SystemDrawing_TestData).Concat(
ArrayTests.Array_TestData);

public static IEnumerable<object[]?> TryWriteObject_UnsupportedObjects_TestData =>
HashtableTests.Hashtables_UnsupportedTestData.Concat(
((IEnumerable<object[]?>)HashtableTests.Hashtables_UnsupportedTestData).Concat(
ListTests.Lists_UnsupportedTestData).Concat(
ListTests.ArrayLists_UnsupportedTestData).Concat(
ArrayTests.Array_UnsupportedTestData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
<PackageReference Include="xunit.stafact" Version="$(XUnitStaFactPackageVersion)" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerPackageVersion)" />
<PackageReference Include="System.Private.Windows.Core.TestUtilities" Version="$(SystemPrivateWindowsCoreTestUtilitiesVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit af32a51

Please # to comment.