Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix tests for net9 #1548

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bunit.generators/bunit.generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/bunit.template/template/Company.BlazorTests1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.18.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="All" />
Expand Down
4 changes: 2 additions & 2 deletions tests/bunit.generators.tests/bunit.generators.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="Verify.SourceGenerators" Version="2.4.0" />
<PackageReference Include="Verify.Xunit" Version="26.2.0" />
<PackageReference Include="Verify.Xunit" Version="26.4.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ namespace Bunit.JSInterop.ComponentSupport;

public class VirtualizeJSRuntimeInvocationHandlerTest : TestContext
{
public static readonly IEnumerable<object[]> ItemsInCollection = new object[][]
{
new object[] { 0 }, new object[] { 7 }, new object[] { 30 }, new object[] { 60 }, new object[] { 100 }, new object[] { 300 }, new object[] { 500 },
};
public static readonly IEnumerable<object[]> ItemsInCollection =
[
[0], [7], [30], [60], [100], [300], [500],
];
linkdotnet marked this conversation as resolved.
Show resolved Hide resolved

[Theory(DisplayName = "Can render component using <Virtualize Items> with ChildContent")]
[MemberData(nameof(ItemsInCollection))]
public void Test001(int itemsInDataSource)
{
var cut = RenderComponent<Virtualize<string>>(ps => ps
.Add(p => p.Items, CreateItems(itemsInDataSource))
#if NET9_0_OR_GREATER
.Add(p => p.MaxItemCount, itemsInDataSource)
#endif
.Add(p => p.ChildContent, item => $"<p>{item}</p>"));

cut.FindAll("p").Count.ShouldBe(itemsInDataSource);
Expand All @@ -33,6 +36,9 @@ public void Test002(int itemsInDataSource)
{
var cut = RenderComponent<Virtualize<string>>(ps => ps
.Add(p => p.Items, CreateItems(itemsInDataSource))
#if NET9_0_OR_GREATER
.Add(p => p.MaxItemCount, itemsInDataSource)
#endif
.Add(p => p.ItemContent, item => $"<p>{item}</p>"));

cut.FindAll("p").Count.ShouldBe(itemsInDataSource);
Expand All @@ -44,6 +50,9 @@ public void Test010(int itemsInDataSource)
{
var cut = RenderComponent<Virtualize<string>>(ps => ps
.Add(p => p.ItemsProvider, CreateItemsProvider(itemsInDataSource))
#if NET9_0_OR_GREATER
.Add(p => p.MaxItemCount, itemsInDataSource)
#endif
.Add(p => p.ChildContent, item => $"<p>{item}</p>"));

cut.FindAll("p").Count.ShouldBe(itemsInDataSource);
Expand All @@ -55,6 +64,9 @@ public void Test011(int itemsInDataSource)
{
var cut = RenderComponent<Virtualize<string>>(ps => ps
.Add(p => p.ItemsProvider, CreateItemsProvider(itemsInDataSource))
#if NET9_0_OR_GREATER
.Add(p => p.MaxItemCount, itemsInDataSource)
#endif
.Add(p => p.ItemContent, item => $"<p>{item}</p>"));

cut.FindAll("p").Count.ShouldBe(itemsInDataSource);
Expand All @@ -63,12 +75,8 @@ public void Test011(int itemsInDataSource)
public static readonly IEnumerable<object[]> ItemCountItemSizeOverscanCount =
ItemsInCollection.Select(x => new object[][]
{
new object[] { x[0], 1, 3 },
new object[] { x[0], 1_000_000, 3 },
new object[] { x[0], 50, 1 },
new object[] { x[0], 50, 1_000_000 },
new object[] { x[0], 1, 1 },
new object[] { x[0], 1_000_000, 1_000_000 },
[x[0], 1, 3], [x[0], 1_000_000, 3], [x[0], 50, 1], [x[0], 50, 1_000_000], [x[0], 1, 1], [x[0], 1_000_000, 1_000_000
],
linkdotnet marked this conversation as resolved.
Show resolved Hide resolved
}).SelectMany(x => x);

[Theory(DisplayName = "Can render component using <Virtualize Items> and different ItemSize and OverscanCount")]
Expand All @@ -79,6 +87,9 @@ public void Test030(int itemsInDataSource, float itemSize, int overscanCount)
.Add(p => p.ItemsProvider, CreateItemsProvider(itemsInDataSource))
.Add(p => p.ItemContent, item => $"<p>{item}</p>")
.Add(p => p.ItemSize, itemSize)
#if NET9_0_OR_GREATER
.Add(p => p.MaxItemCount, itemsInDataSource)
#endif
.Add(p => p.OverscanCount, overscanCount));

cut.FindAll("p").Count.ShouldBe(itemsInDataSource);
Expand All @@ -91,6 +102,9 @@ public void Test040(int itemsInDataSource)
var cut = RenderComponent<Virtualize<string>>(ps => ps
.Add(p => p.ItemsProvider, _ => ValueTask.FromResult(new ItemsProviderResult<string>(Array.Empty<string>(), itemsInDataSource)))
.Add(p => p.ItemContent, item => @$"<p class=""item"">{item}</p>")
#if NET9_0_OR_GREATER
.Add(p => p.MaxItemCount, itemsInDataSource)
#endif
.Add(p => p.Placeholder, _ => @"<p class=""placeholder"" />"));

cut.FindAll(".placeholder").Count.ShouldBe(itemsInDataSource);
Expand Down
Loading