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

refactor: Update component types in Bunit extensions and tests #409

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
3 changes: 1 addition & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="RavenDB.TestDriver" Version="7.0.0" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="bunit" Version="2.0.24-preview" />
<PackageVersion Include="bunit.generators" Version="2.0.24-preview" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<PackageVersion Include="bunit" Version="2.0.36-preview" />
<PackageVersion Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1 change: 0 additions & 1 deletion tests/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="bunit.generators" />
<PackageReference Include="bunit" />
<PackageReference Include="Shouldly" />
<PackageReference Include="NSubstitute" />
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public async Task ShouldSaveBlogPostOnSave()
instantRegistry.Received(1).RunInstantJob<SimilarBlogPostJob>(Arg.Any<object>(), Arg.Any<CancellationToken>());
}

private static void TriggerNewBlogPost(RenderedComponent<CreateNewBlogPost> cut)
private static void TriggerNewBlogPost(IRenderedComponent<CreateNewBlogPost> cut)
{
cut.Find("#title").Input("My Title");
cut.Find("#short").Input("My short Description");
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
using LinkDotNet.Blog.Web.Features.Admin.BlogPostEditor.Components;
using LinkDotNet.Blog.Web.Features.Components;
using LinkDotNet.Blog.Web.Features.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using NCronJob;
@@ -68,7 +69,7 @@ public void ShouldThrowWhenNoIdProvided()
act.ShouldThrow<ArgumentNullException>();
}

private static void TriggerUpdate(RenderedFragment cut)
private static void TriggerUpdate(IRenderedComponent<IComponent> cut)
{
cut.Find("#short").Input("My new Description");

Original file line number Diff line number Diff line change
@@ -177,10 +177,10 @@ private static void SetupGetAll(
return (repoMock, calcMock);
}

private RenderedComponent<Profile> RenderProfileWithEmptyInformation()
private IRenderedComponent<Profile> RenderProfileWithEmptyInformation()
=> Render<Profile>(p => p.Add(s => s.ProfileInformation, new ProfileInformationBuilder().Build()));

private RenderedComponent<Profile> RenderProfileInAdmin()
private IRenderedComponent<Profile> RenderProfileInAdmin()
=> Render<Profile>(p => p
.Add(s => s.ProfileInformation, new ProfileInformationBuilder().Build())
.Add(s => s.ShowAdminActions, true));
4 changes: 2 additions & 2 deletions tests/LinkDotNet.Blog.TestUtilities/BunitExtensions.cs
Original file line number Diff line number Diff line change
@@ -5,14 +5,14 @@ namespace LinkDotNet.Blog.TestUtilities;

public static class BunitExtensions
{
public static RenderedComponent<TComponent> WaitForComponent<TComponent>(this RenderedFragment component)
public static IRenderedComponent<TComponent> WaitForComponent<TComponent>(this IRenderedComponent<IComponent> component)
where TComponent : IComponent
{
component.WaitForState(component.HasComponent<TComponent>);
return component.FindComponent<TComponent>();
}

public static IReadOnlyList<RenderedComponent<TComponent>> WaitForComponents<TComponent>(this RenderedFragment component)
public static IReadOnlyList<IRenderedComponent<TComponent>> WaitForComponents<TComponent>(this IRenderedComponent<IComponent> component)
where TComponent : IComponent
{
component.WaitForState(component.HasComponent<TComponent>);
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ public void ShouldSetCanoncialLinkWithoutQueryParameter()
}

private static void AssertMetaTagExistsWithValue(
RenderedFragment cut,
IRenderedComponent<IComponent> cut,
string metaTag,
string metaTagValue,
string? ogPropertyName = null)
@@ -87,7 +87,7 @@ private static void AssertMetaTagExistsWithValue(
}

private static bool GetMetaTagExists(
RenderedFragment cut,
IRenderedComponent<IComponent> cut,
string metaTag)
{
var metaTags = cut.FindAll("meta");
Loading