Skip to content

Commit 3cffa44

Browse files
committed
feat: update package versions and refactor tests for improved stability and clarity
1 parent 89e258f commit 3cffa44

10 files changed

Lines changed: 18 additions & 28 deletions

File tree

Directory.Packages.props

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
<PackageVersion Include="Azure.Storage.Blobs" Version="12.27.0" />
1515
<PackageVersion Include="Blazored.LocalStorage" Version="4.3.0" />
1616
<PackageVersion Include="Bogus" Version="35.6.5" />
17-
<PackageVersion Include="bunit" Version="1.40.0" />
18-
<PackageVersion Include="bunit.web" Version="1.40.0" />
19-
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
17+
<PackageVersion Include="bunit" Version="2.7.2" />
2018
<PackageVersion Include="JasperFx.Core" Version="1.12.0" />
2119
<PackageVersion Include="MailKit" Version="4.15.1" />
2220
<PackageVersion Include="Marten" Version="8.18.0" />
@@ -53,11 +51,11 @@
5351
<PackageVersion Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.1" />
5452
<PackageVersion Include="SkiaSharp.NativeAssets.macOS" Version="3.119.1" />
5553
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
56-
<PackageVersion Include="TUnit" Version="1.12.15" />
54+
<PackageVersion Include="TUnit" Version="1.36.0" />
5755
<PackageVersion Include="Weasel.Core" Version="8.4.3" />
5856
<PackageVersion Include="WolverineFx.Http" Version="5.11.0" />
5957
<PackageVersion Include="WolverineFx.Marten" Version="5.11.0" />
60-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.102" />
58+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.202" />
6159
<PackageVersion Include="Roslynator.Analyzers" Version="4.15.0" />
6260
</ItemGroup>
6361
</Project>

tests/BookStore.ApiService.UnitTests/BookStore.ApiService.UnitTests.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="coverlet.collector">
12-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13-
<PrivateAssets>all</PrivateAssets>
14-
</PackageReference>
1511
<PackageReference Include="NSubstitute" />
1612
<PackageReference Include="TUnit" />
1713
</ItemGroup>

tests/BookStore.AppHost.Tests/AuthTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ namespace BookStore.AppHost.Tests;
99

1010
public class AuthTests
1111
{
12-
readonly IIdentityClient _client;
12+
IIdentityClient _client = null!;
1313

14-
public AuthTests()
14+
[Before(Test)]
15+
public void Setup()
1516
{
1617
var httpClient = HttpClientHelpers.GetUnauthenticatedClient();
1718
_client = RestService.For<IIdentityClient>(httpClient);

tests/BookStore.AppHost.Tests/BookStore.AppHost.Tests.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
<PackageReference Include="Azure.Storage.Blobs" />
1313
<PackageReference Include="Bogus" />
1414
<PackageReference Include="Microsoft.Playwright" />
15-
<PackageReference Include="coverlet.collector">
16-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17-
<PrivateAssets>all</PrivateAssets>
18-
</PackageReference>
1915
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
2016
<PackageReference Include="Marten" />
2117
<PackageReference Include="Npgsql" />

tests/BookStore.AppHost.Tests/MultiLanguageTranslationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public async Task Book_Update_ShouldPreserveAllDescriptions()
148148
}
149149
};
150150

151-
var updatedBook = await BookHelpers.UpdateBookAsync(client, book.Id, updateRequest, book.ETag);
151+
var updatedBook = await BookHelpers.UpdateBookAsync(client, book.Id, updateRequest, etag!);
152152
_ = await Assert.That(updatedBook).IsNotNull();
153153

154154
// 4. Verify using Accept-Language

tests/BookStore.Web.Tests/BookStore.Web.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<PackageReference Include="Aspire.Hosting.Testing" />
1212
<PackageReference Include="Bogus" />
1313
<PackageReference Include="bunit" />
14-
<PackageReference Include="bunit.web" />
1514
<PackageReference Include="Microsoft.JSInterop" />
1615
<PackageReference Include="Microsoft.AspNetCore.Components.Web" />
1716
<PackageReference Include="MudBlazor" />

tests/BookStore.Web.Tests/Components/AddBookDialogTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ await dialogProvider.InvokeAsync(async () =>
102102
dialogProvider.WaitForState(() => dialogProvider.Markup.Contains("Edit Book", StringComparison.Ordinal));
103103

104104
// Assert pre-population
105-
var expectedPriceValue = existingGbpPrice.ToString(System.Globalization.CultureInfo.CurrentCulture);
105+
var expectedPriceValue = existingGbpPrice.ToString(System.Globalization.CultureInfo.InvariantCulture);
106106
var gbpInput = dialogProvider.Find($"input[value='{expectedPriceValue}']");
107107
_ = await Assert.That(gbpInput.GetAttribute("value")).IsEqualTo(expectedPriceValue);
108108

tests/BookStore.Web.Tests/Components/CurrencySelectorTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public async Task CurrencySelector_ShouldRenderCurrentCurrency()
3838
var cut = RenderComponent<CurrencySelector>();
3939

4040
// Assert
41-
var input = cut.Find("input");
42-
_ = await Assert.That(input.GetAttribute("value")).IsEqualTo("GBP");
41+
var button = cut.Find("button[aria-label='Change Currency']");
42+
_ = await Assert.That(button.TextContent).Contains("GBP");
4343
}
4444

4545
[Test]
@@ -52,7 +52,7 @@ public async Task CurrencySelector_ShouldChangeCurrency_OnClick()
5252
await cut.InvokeAsync(async () => await _currencyService.SetCurrencyAsync("EUR"));
5353

5454
// Assert
55-
var input = cut.Find("input");
56-
_ = await Assert.That(input.GetAttribute("value")).IsEqualTo("EUR");
55+
var button = cut.Find("button[aria-label='Change Currency']");
56+
_ = await Assert.That(button.TextContent).Contains("EUR");
5757
}
5858
}

tests/BookStore.Web.Tests/Infrastructure/BunitTestContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BookStore.Web.Tests.Infrastructure;
77

88
public abstract class BunitTestContext : IDisposable
99
{
10-
protected Bunit.TestContext Context { get; } = new();
10+
protected BunitContext Context { get; } = new();
1111

1212
protected BunitTestContext()
1313
{
@@ -36,7 +36,7 @@ protected IRenderedComponent<TComponent> RenderComponent<TComponent>(
3636
Action<ComponentParameterCollectionBuilder<TComponent>>? parameterBuilder = null)
3737
where TComponent : Microsoft.AspNetCore.Components.IComponent
3838
{
39-
_ = Context.RenderComponent<MudPopoverProvider>();
40-
return Context.RenderComponent(parameterBuilder);
39+
_ = Context.Render<MudPopoverProvider>();
40+
return Context.Render(parameterBuilder);
4141
}
4242
}

tests/BookStore.Web.Tests/Services/TenantServiceTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Setup()
2626
_localStorage = Substitute.For<ILocalStorageService>();
2727
_js = Substitute.For<IJSRuntime>();
2828

29-
// NavigationManager is already registered in bUnit Context.Services as FakeNavigationManager
29+
// NavigationManager is already registered in bUnit Context.Services as BunitNavigationManager
3030
var navigation = Context.Services.GetRequiredService<NavigationManager>();
3131

3232
_sut = new TenantService(_tenantClient, navigation, _localStorage, _js);
@@ -39,7 +39,7 @@ public void Setup()
3939
public async Task InitializeAsync_ShouldSetTenantFromUrl_WhenPresent()
4040
{
4141
// Arrange
42-
var navigation = Context.Services.GetRequiredService<FakeNavigationManager>();
42+
var navigation = Context.Services.GetRequiredService<BunitNavigationManager>();
4343
navigation.NavigateTo("http://localhost/?tenant=apple");
4444

4545
var tenantInfo = new TenantInfoDto("apple", "Apple Store", "Tagline", "#FFFFFF", true);
@@ -58,7 +58,7 @@ public async Task InitializeAsync_ShouldSetTenantFromUrl_WhenPresent()
5858
public async Task InitializeAsync_ShouldFallbackToLocalStorage_WhenUrlEmpty()
5959
{
6060
// Arrange
61-
var navigation = Context.Services.GetRequiredService<FakeNavigationManager>();
61+
var navigation = Context.Services.GetRequiredService<BunitNavigationManager>();
6262
navigation.NavigateTo("http://localhost/");
6363

6464
_ = _localStorage.GetItemAsStringAsync("selected-tenant").Returns("banana");

0 commit comments

Comments
 (0)