diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 03ec54546..f4e641aaf 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -9,3 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
\ No newline at end of file
diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml
index ab6079984..1beb008e7 100644
--- a/.github/workflows/docs-deploy.yml
+++ b/.github/workflows/docs-deploy.yml
@@ -23,16 +23,16 @@ jobs:
steps:
- name: ๐ Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.BUNIT_BOT_TOKEN }}
- name: โ๏ธ Import GPG key
id: import_gpg
- uses: crazy-max/ghaction-import-gpg@v3
+ uses: crazy-max/ghaction-import-gpg@v5
with:
- gpg-private-key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
+ gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }}
- name: โ๏ธ Setup CI GIT
@@ -68,7 +68,6 @@ jobs:
5.0.x
6.0.x
7.0.x
- include-prerelease: true
- name: ๐จ Setup color
run: |
@@ -88,7 +87,7 @@ jobs:
- name: ๐ ๏ธ Deploy to GitHub Pages
if: success()
- uses: crazy-max/ghaction-github-pages@v2
+ uses: crazy-max/ghaction-github-pages@v3
with:
build_dir: docs/site/_site
fqdn: bunit.dev
@@ -111,7 +110,7 @@ jobs:
- name: โญ Create pull request from stable to main when direct merge fails
if: steps.mergeMainline.outcome == 'failure'
- uses: thomaseizinger/create-pull-request@1.0.0
+ uses: thomaseizinger/create-pull-request@1.3.0
env:
GITHUB_TOKEN: ${{ secrets.BUNIT_BOT_TOKEN }}
with:
diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml
index bc57aa94f..b313121fc 100644
--- a/.github/workflows/prepare-release.yml
+++ b/.github/workflows/prepare-release.yml
@@ -16,7 +16,7 @@ jobs:
if: github.ref == 'refs/heads/main' && contains(fromJson('["major","minor"]'), github.event.inputs.versionIncrement)
steps:
- name: ๐ Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.BUNIT_BOT_TOKEN }}
@@ -35,9 +35,9 @@ jobs:
exit 1
- name: โ๏ธ Import GPG key
id: import_gpg
- uses: crazy-max/ghaction-import-gpg@v3
+ uses: crazy-max/ghaction-import-gpg@v5
with:
- gpg-private-key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
+ gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }}
- name: โ๏ธ Setup CI GIT
@@ -56,9 +56,9 @@ jobs:
id: versions
run: |
nbgv prepare-release --versionIncrement ${{ github.event.inputs.versionIncrement }}
- echo "::set-output name=MAIN_VERSION_COMMIT_MESSAGE::$(git log --format=%B -n 1 --skip 1)"
+ echo "MAIN_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1 --skip 1)" >> $GITHUB_OUTPUT
git checkout release/v$NBGV_MajorMinorVersion
- echo "::set-output name=RELEASE_VERSION_COMMIT_MESSAGE::$(git log --format=%B -n 1)"
+ echo "RELEASE_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1)" >> $GITHUB_OUTPUT
# Workaround since nbgv prepare-release does not sign commits.
# This undo's the commits, keeps the version changes, and commits again with signing
@@ -83,7 +83,7 @@ jobs:
run: git push origin release/v$NBGV_MajorMinorVersion
- name: โญ Create pull request for release branch
- uses: thomaseizinger/create-pull-request@1.0.0
+ uses: thomaseizinger/create-pull-request@1.3.0
env:
GITHUB_TOKEN: ${{ secrets.BUNIT_BOT_TOKEN }}
with:
diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml
index b36b5fc1f..04dafe027 100644
--- a/.github/workflows/release-preview.yml
+++ b/.github/workflows/release-preview.yml
@@ -21,7 +21,7 @@ jobs:
steps:
- name: ๐ Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
fetch-depth: 0
@@ -36,7 +36,6 @@ jobs:
5.0.x
6.0.x
7.0.x
- include-prerelease: true
- name: ๐จ Setup color
run: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 44794ffec..f72dc1725 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -42,9 +42,9 @@ jobs:
- name: โ๏ธ Import GPG key
id: import_gpg
- uses: crazy-max/ghaction-import-gpg@v3
+ uses: crazy-max/ghaction-import-gpg@v5
with:
- gpg-private-key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
+ gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }}
- name: โ๏ธ Setup CI GIT
@@ -67,10 +67,9 @@ jobs:
5.0.x
6.0.x
7.0.x
- include-prerelease: true
- name: ๐ ๏ธ Update changelog
- uses: thomaseizinger/keep-a-changelog-new-release@1.2.1
+ uses: thomaseizinger/keep-a-changelog-new-release@1.3.0
with:
version: ${{ env.NBGV_SemVer2 }}
@@ -126,7 +125,7 @@ jobs:
- name: โญ Create pull request from stable to main when direct merge fails
if: steps.mergeMainline.outcome == 'failure'
- uses: thomaseizinger/create-pull-request@1.0.0
+ uses: thomaseizinger/create-pull-request@1.3.0
env:
GITHUB_TOKEN: ${{ secrets.BUNIT_BOT_TOKEN }}
with:
diff --git a/.github/workflows/verification.yml b/.github/workflows/verification.yml
index cf1e81d3b..c85166719 100644
--- a/.github/workflows/verification.yml
+++ b/.github/workflows/verification.yml
@@ -32,7 +32,7 @@ jobs:
steps:
- name: ๐ Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
fetch-depth: 0
@@ -44,7 +44,6 @@ jobs:
5.0.x
6.0.x
7.0.x
- include-prerelease: true
- name: ๐จ Setup color
if: matrix.os != 'windows-latest'
@@ -64,10 +63,10 @@ jobs:
- name: ๐งช Run unit tests (async)
run: |
- dotnet test --filter Category!=sync -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full
+ dotnet test --filter Category!=sync -c release
- name: ๐งช Run unit tests (sync)
run: |
- dotnet test --filter Category!=async -c release --blame-hang-timeout 15s --blame-hang-dump-type full --blame-crash-dump-type full
+ dotnet test --filter Category!=async -c release
- name: ๐ Upload hang- and crash-dumps on test failure
if: failure()
uses: actions/upload-artifact@v3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8b6d65ef1..9dd8a7bdb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ All notable changes to **bUnit** will be documented in this file. The project ad
## [Unreleased]
+This release contains a bunch of small tweaks and fixes.
+
## [1.12.6] - 2022-11-08
### Fixed
diff --git a/Directory.Build.props b/Directory.Build.props
index 6716de106..de171a5f4 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -48,7 +48,7 @@
-
+
@@ -14,6 +16,11 @@ public WaitForFailedException(string? errorMessage, Exception? innerException =
{
}
+ internal WaitForFailedException(string errorMessage, int checkCount, int componentRenderCount, int totalRenderCount, Exception? innerException = null)
+ : base(errorMessage + $" Check count: {checkCount}. Component render count: {componentRenderCount}. Total render count: {totalRenderCount}.", innerException)
+ {
+ }
+
private WaitForFailedException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
diff --git a/src/bunit.core/Extensions/WaitForHelpers/WaitForHelper.cs b/src/bunit.core/Extensions/WaitForHelpers/WaitForHelper.cs
index d49411bc3..7b10c7a80 100644
--- a/src/bunit.core/Extensions/WaitForHelpers/WaitForHelper.cs
+++ b/src/bunit.core/Extensions/WaitForHelpers/WaitForHelper.cs
@@ -14,7 +14,9 @@ public abstract class WaitForHelper : IDisposable
private readonly Func<(bool CheckPassed, T Content)> completeChecker;
private readonly IRenderedFragmentBase renderedFragment;
private readonly ILogger> logger;
+ private readonly TestRenderer renderer;
private bool isDisposed;
+ private int checkCount;
private Exception? capturedException;
///
@@ -49,15 +51,24 @@ protected WaitForHelper(
{
this.renderedFragment = renderedFragment ?? throw new ArgumentNullException(nameof(renderedFragment));
this.completeChecker = completeChecker ?? throw new ArgumentNullException(nameof(completeChecker));
-
+
logger = renderedFragment.Services.CreateLogger>();
+ renderer = (TestRenderer)renderedFragment
+ .Services
+ .GetRequiredService();
checkPassedCompletionSource = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
timer = new Timer(_ =>
{
logger.LogWaiterTimedOut(renderedFragment.ComponentId);
- checkPassedCompletionSource.TrySetException(new WaitForFailedException(TimeoutErrorMessage, capturedException));
+ checkPassedCompletionSource.TrySetException(
+ new WaitForFailedException(
+ TimeoutErrorMessage ?? string.Empty,
+ checkCount,
+ renderedFragment.RenderCount,
+ renderer.RenderCount,
+ capturedException));
});
- WaitTask = CreateWaitTask(renderedFragment);
+ WaitTask = CreateWaitTask();
timer.Change(GetRuntimeTimeout(timeout), Timeout.InfiniteTimeSpan);
InitializeWaiting();
@@ -113,12 +124,8 @@ private void InitializeWaiting()
}
}
- private Task CreateWaitTask(IRenderedFragmentBase renderedFragment)
- {
- var renderer = renderedFragment
- .Services
- .GetRequiredService();
-
+ private Task CreateWaitTask()
+ {
// Two to failure conditions, that the renderer captures an unhandled
// exception from a component or itself, or that the timeout is reached,
// are executed on the renderers scheduler, to ensure that OnAfterRender
@@ -144,6 +151,7 @@ private void OnAfterRender(object? sender, EventArgs args)
logger.LogCheckingWaitCondition(renderedFragment.ComponentId);
var checkResult = completeChecker();
+ checkCount++;
if (checkResult.CheckPassed)
{
checkPassedCompletionSource.TrySetResult(checkResult.Content);
@@ -157,13 +165,19 @@ private void OnAfterRender(object? sender, EventArgs args)
}
catch (Exception ex)
{
+ checkCount++;
capturedException = ex;
logger.LogCheckThrow(renderedFragment.ComponentId, ex);
if (StopWaitingOnCheckException)
{
checkPassedCompletionSource.TrySetException(
- new WaitForFailedException(CheckThrowErrorMessage, capturedException));
+ new WaitForFailedException(
+ CheckThrowErrorMessage ?? string.Empty,
+ checkCount,
+ renderedFragment.RenderCount,
+ renderer.RenderCount,
+ capturedException));
Dispose();
}
}
diff --git a/src/bunit.core/Rendering/RootRenderTree.cs b/src/bunit.core/Rendering/RootRenderTree.cs
index 96dc24f89..c8ca60c7d 100644
--- a/src/bunit.core/Rendering/RootRenderTree.cs
+++ b/src/bunit.core/Rendering/RootRenderTree.cs
@@ -7,6 +7,7 @@ namespace Bunit.Rendering;
/// Components added to the render tree must have either a ChildContent or
/// Body parameter.
///
+[SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "A tree is a collection by default.")]
public sealed class RootRenderTree : IReadOnlyCollection
{
private readonly List registrations = new();
diff --git a/src/bunit.core/Rendering/TestRenderer.cs b/src/bunit.core/Rendering/TestRenderer.cs
index 7ad4faae0..c4934ed9d 100644
--- a/src/bunit.core/Rendering/TestRenderer.cs
+++ b/src/bunit.core/Rendering/TestRenderer.cs
@@ -21,6 +21,11 @@ public class TestRenderer : Renderer, ITestRenderer
///
public override Dispatcher Dispatcher { get; } = Dispatcher.CreateDefault();
+ ///
+ /// Gets the number of render cycles that has been performed.
+ ///
+ internal int RenderCount { get; private set; }
+
///
/// Initializes a new instance of the class.
///
@@ -151,6 +156,8 @@ protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
{
logger.LogNewRenderBatchReceived();
+ RenderCount++;
+
var renderEvent = new RenderEvent(renderBatch, new RenderTreeFrameDictionary());
// removes disposed components
@@ -201,6 +208,7 @@ protected override void Dispose(bool disposing)
}
renderedComponents.Clear();
+ unhandledExceptionTsc.TrySetCanceled();
}
base.Dispose(disposing);
diff --git a/src/bunit.core/StringSyntaxAttribute.cs b/src/bunit.core/StringSyntaxAttribute.cs
index 8817b14fd..b79b8a512 100644
--- a/src/bunit.core/StringSyntaxAttribute.cs
+++ b/src/bunit.core/StringSyntaxAttribute.cs
@@ -2,7 +2,8 @@
namespace System.Diagnostics.CodeAnalysis;
/// Fake version of the StringSyntaxAttribute, which was introduced in .NET 7
-[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
+[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+[SuppressMessage("Design", "CA1019:Define accessors for attribute arguments", Justification = "The sole purpose is to have the same public surface as the class in .NET7 and above.")]
public sealed class StringSyntaxAttribute : Attribute
{
///
diff --git a/src/bunit.web/Asserting/DiffAssertExtensions.cs b/src/bunit.web/Asserting/DiffAssertExtensions.cs
index f7477e212..1827b45ac 100644
--- a/src/bunit.web/Asserting/DiffAssertExtensions.cs
+++ b/src/bunit.web/Asserting/DiffAssertExtensions.cs
@@ -18,10 +18,18 @@ public static IDiff ShouldHaveSingleChange(this IEnumerable diffs)
{
if (diffs is null)
throw new ArgumentNullException(nameof(diffs));
- if (diffs.Take(2).Count() != 1) // Optimized way of writing "diffs.Count() != 1"
- throw new ActualExpectedAssertException(diffs.Count().ToString(CultureInfo.InvariantCulture), "1", "Actual changes", "Expected changes", "There were more than one change");
- return diffs.First();
+ var diffsArray = diffs.ToArray();
+
+ if (diffsArray.Length != 1)
+ throw new ActualExpectedAssertException(
+ actual: diffsArray.Length.ToString(CultureInfo.InvariantCulture),
+ expected: "1",
+ actualText: "Actual changes",
+ expectedText: "Expected changes",
+ message: "There were more than one change");
+
+ return diffsArray.First();
}
///
@@ -38,11 +46,18 @@ public static void ShouldHaveChanges(this IEnumerable diffs, params Actio
if (diffInspectors is null)
throw new ArgumentNullException(nameof(diffInspectors));
- if (diffs.Take(diffInspectors.Length + 1).Count() != diffInspectors.Length) // Optimized way of writing "diffs.Count() != diffInspectors.Length"
- throw new ActualExpectedAssertException(diffs.Count().ToString(CultureInfo.InvariantCulture), diffInspectors.Length.ToString(CultureInfo.InvariantCulture), "Actual changes", "Expected changes", "The actual number of changes does not match the expected.");
+ var diffsArray = diffs.ToArray();
+
+ if (diffsArray.Length != diffInspectors.Length)
+ throw new ActualExpectedAssertException(
+ actual: diffsArray.Length.ToString(CultureInfo.InvariantCulture),
+ expected: diffInspectors.Length.ToString(CultureInfo.InvariantCulture),
+ actualText: "Actual changes",
+ expectedText: "Expected changes",
+ message: "The actual number of changes does not match the expected.");
- int index = 0;
- foreach (var diff in diffs)
+ var index = 0;
+ foreach (var diff in diffsArray)
{
diffInspectors[index](diff);
index++;
diff --git a/src/bunit.web/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensions.cs b/src/bunit.web/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensions.cs
index eb1e3b524..e9fe9da28 100644
--- a/src/bunit.web/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensions.cs
+++ b/src/bunit.web/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensions.cs
@@ -159,13 +159,11 @@ private static IElement WaitForElementCore(this IRenderedFragment renderedFragme
{
return waiter.WaitTask.GetAwaiter().GetResult();
}
- catch (Exception e)
+ catch (AggregateException e) when (e.InnerExceptions.Count == 1)
{
- if (e is AggregateException aggregateException && aggregateException.InnerExceptions.Count == 1)
- {
- ExceptionDispatchInfo.Capture(aggregateException.InnerExceptions[0]).Throw();
- }
+ ExceptionDispatchInfo.Capture(e.InnerExceptions[0]).Throw();
+ // Unreachable code
throw;
}
}
@@ -189,13 +187,11 @@ private static IRefreshableElementCollection WaitForElementsCore(
{
return waiter.WaitTask.GetAwaiter().GetResult();
}
- catch (Exception e)
+ catch (AggregateException e) when (e.InnerExceptions.Count == 1)
{
- if (e is AggregateException aggregateException && aggregateException.InnerExceptions.Count == 1)
- {
- ExceptionDispatchInfo.Capture(aggregateException.InnerExceptions[0]).Throw();
- }
+ ExceptionDispatchInfo.Capture(e.InnerExceptions[0]).Throw();
+ // Unreachable code
throw;
}
}
diff --git a/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs b/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs
index 67fb256ca..5ef031652 100644
--- a/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs
+++ b/src/bunit.web/JSInterop/JSRuntimeInvocationDictionary.cs
@@ -15,12 +15,7 @@ public sealed class JSRuntimeInvocationDictionary : IReadOnlyCollection
/// The identifier to get invocations for.
/// An .
- public IReadOnlyList this[string identifier]
- {
- get => invocations.ContainsKey(identifier)
- ? invocations[identifier]
- : Array.Empty();
- }
+ public IReadOnlyList this[string identifier] => invocations.TryGetValue(identifier, out var value) ? value : Array.Empty();
///
/// Gets a read only collection of all the identifiers used in invocations in this dictionary.
diff --git a/src/bunit.web/Rendering/Internal/Htmlizer.cs b/src/bunit.web/Rendering/Internal/Htmlizer.cs
index 4b787a7b4..587b07e91 100644
--- a/src/bunit.web/Rendering/Internal/Htmlizer.cs
+++ b/src/bunit.web/Rendering/Internal/Htmlizer.cs
@@ -261,7 +261,7 @@ private static int RenderAttributes(
result.Append(':');
result.Append(nameParts[1]);
break;
- case bool flag and true:
+ case true:
result.Append(' ');
result.Append(frame.AttributeName);
break;
diff --git a/src/bunit.web/TestDoubles/Authorization/FakeAuthorizationService.cs b/src/bunit.web/TestDoubles/Authorization/FakeAuthorizationService.cs
index 6cf8ef1ce..572863b89 100644
--- a/src/bunit.web/TestDoubles/Authorization/FakeAuthorizationService.cs
+++ b/src/bunit.web/TestDoubles/Authorization/FakeAuthorizationService.cs
@@ -66,17 +66,20 @@ public Task AuthorizeAsync(ClaimsPrincipal user, object? re
AuthorizationResult result;
- if (requirements.All(p => p is DenyAnonymousAuthorizationRequirement))
+ var requirementsArray = requirements.ToArray();
+ if (requirementsArray.All(p => p is DenyAnonymousAuthorizationRequirement))
{
- result = (currentState == AuthorizationState.Authorized) ? AuthorizationResult.Success() : AuthorizationResult.Failed();
+ result = currentState == AuthorizationState.Authorized
+ ? AuthorizationResult.Success()
+ : AuthorizationResult.Failed();
}
- else if (requirements.All(p => p is RolesAuthorizationRequirement))
+ else if (requirementsArray.All(p => p is RolesAuthorizationRequirement))
{
- result = VerifyRequiredRoles(requirements);
+ result = VerifyRequiredRoles(requirementsArray);
}
else if (supportedPolicies is not null)
{
- result = VerifyRequiredPolicies(requirements);
+ result = VerifyRequiredPolicies(requirementsArray);
}
else
{
@@ -103,35 +106,28 @@ public Task AuthorizeAsync(ClaimsPrincipal user, object? re
return AuthorizeAsync(user, resource, requirements);
}
- private AuthorizationResult VerifyRequiredPolicies(IEnumerable requirements)
+ private AuthorizationResult VerifyRequiredPolicies(IReadOnlyCollection requirements)
{
if (supportedPolicies.IsNullOrEmpty() || requirements.IsNullOrEmpty())
{
return AuthorizationResult.Failed();
}
- foreach (IAuthorizationRequirement req in requirements)
- {
- if (req is TestPolicyRequirement testReq && supportedPolicies.Contains(testReq.PolicyName, StringComparer.Ordinal))
- return AuthorizationResult.Success();
- }
-
- return AuthorizationResult.Failed();
+ return requirements.OfType().Any(req => supportedPolicies.Contains(req.PolicyName, StringComparer.Ordinal))
+ ? AuthorizationResult.Success()
+ : AuthorizationResult.Failed();
}
- private AuthorizationResult VerifyRequiredRoles(IEnumerable requirements)
+ private AuthorizationResult VerifyRequiredRoles(IReadOnlyCollection requirements)
{
- AuthorizationResult result = AuthorizationResult.Failed();
- foreach (IAuthorizationRequirement req in requirements)
+ var result = AuthorizationResult.Failed();
+ foreach (var req in requirements.OfType())
{
- if (req is RolesAuthorizationRequirement testReq)
+ var rolesFound = req.AllowedRoles.Intersect(supportedRoles, StringComparer.Ordinal);
+ if (rolesFound.Any())
{
- IEnumerable rolesFound = testReq.AllowedRoles.Intersect(supportedRoles, StringComparer.Ordinal);
- if (rolesFound.Any())
- {
- result = AuthorizationResult.Success();
- break;
- }
+ result = AuthorizationResult.Success();
+ break;
}
}
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
index 740ea9e19..92998b452 100644
--- a/tests/Directory.Build.props
+++ b/tests/Directory.Build.props
@@ -17,7 +17,7 @@
-
+
diff --git a/tests/bunit.core.tests/ComponentFactories/GenericComponentFactoryTest.cs b/tests/bunit.core.tests/ComponentFactories/GenericComponentFactoryTest.cs
index ff6c83343..592abab61 100644
--- a/tests/bunit.core.tests/ComponentFactories/GenericComponentFactoryTest.cs
+++ b/tests/bunit.core.tests/ComponentFactories/GenericComponentFactoryTest.cs
@@ -25,7 +25,7 @@ public void Test002()
cut.MarkupMatches(@"Has ref = True
");
}
- private class FakeSimple1 : Simple1
+ private sealed class FakeSimple1 : Simple1
{
protected override void OnInitialized() { }
protected override Task OnInitializedAsync() => Task.CompletedTask;
diff --git a/tests/bunit.core.tests/ComponentParameterCollectionBuilderTests.cs b/tests/bunit.core.tests/ComponentParameterCollectionBuilderTests.cs
index c6481eb36..240e46287 100644
--- a/tests/bunit.core.tests/ComponentParameterCollectionBuilderTests.cs
+++ b/tests/bunit.core.tests/ComponentParameterCollectionBuilderTests.cs
@@ -720,9 +720,9 @@ private class Params : ComponentBase
public void SomeMethod() { }
}
- private class NoParams : ComponentBase { }
- private class NonChildContentParameter : ComponentBase { public RenderFragment? ChildContent { get; set; } }
- private class InhertedParams : Params { }
+ private sealed class NoParams : ComponentBase { }
+ private sealed class NonChildContentParameter : ComponentBase { public RenderFragment? ChildContent { get; set; } }
+ private sealed class InhertedParams : Params { }
private abstract class ParamsBase : ComponentBase
{
public abstract T Value { get; set; }
@@ -733,21 +733,21 @@ private class InheritedParamsWithOverride : ParamsBase
[Parameter] public override bool? Value { get; set; }
}
- private class InheritedParamsWithoutOverride : InheritedParamsWithOverride
+ private sealed class InheritedParamsWithoutOverride : InheritedParamsWithOverride
{ }
- private class TemplatedChildContent : ComponentBase
+ private sealed class TemplatedChildContent : ComponentBase
{
[Parameter] public RenderFragment? ChildContent { get; set; }
}
- private class NoTwoWayBind : ComponentBase
+ private sealed class NoTwoWayBind : ComponentBase
{
[Parameter]
public string Value { get; set; }
}
- private class InvalidTwoWayBind : ComponentBase
+ private sealed class InvalidTwoWayBind : ComponentBase
{
[Parameter]
public string Value { get; set; }
@@ -755,13 +755,13 @@ private class InvalidTwoWayBind : ComponentBase
public EventCallback ValueChanged { get; set; }
}
- private class ComponentWithCascadingParameter : ComponentBase
+ private sealed class ComponentWithCascadingParameter : ComponentBase
{
[CascadingParameter] public string Value { get; set; } = string.Empty;
[Parameter] public EventCallback ValueChanged { get; set; }
}
- private class ValidNamesComponent : ComponentBase
+ private sealed class ValidNamesComponent : ComponentBase
{
[Parameter] public DateTime LastChanged { get; set; }
[Parameter] public EventCallback LastChangedChanged { get; set; }
diff --git a/tests/bunit.core.tests/ComponentParameterCollectionTest.cs b/tests/bunit.core.tests/ComponentParameterCollectionTest.cs
index b41243247..6a809a206 100644
--- a/tests/bunit.core.tests/ComponentParameterCollectionTest.cs
+++ b/tests/bunit.core.tests/ComponentParameterCollectionTest.cs
@@ -335,7 +335,7 @@ public void Test055()
Should.Throw(() => sut.ToRenderFragment());
}
- private class Params : ComponentBase
+ private sealed class Params : ComponentBase
{
public const string TemplateContent = "FOO";
diff --git a/tests/bunit.core.tests/ComponentParameterFactoryTest.cs b/tests/bunit.core.tests/ComponentParameterFactoryTest.cs
index 987818a0b..e642e2317 100644
--- a/tests/bunit.core.tests/ComponentParameterFactoryTest.cs
+++ b/tests/bunit.core.tests/ComponentParameterFactoryTest.cs
@@ -263,7 +263,7 @@ public void Test063()
renderedFragment.Markup.ShouldBe(nameof(TestComponent) + EXPECTED);
}
- private class TestComponent : ComponentBase
+ private sealed class TestComponent : ComponentBase
{
[Parameter] public string? Input { get; set; }
[Parameter] public RenderFragment? Template { get; set; }
diff --git a/tests/bunit.core.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensionsTest.cs b/tests/bunit.core.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensionsTest.cs
index 6a19a20e2..7a73e4dcb 100644
--- a/tests/bunit.core.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensionsTest.cs
+++ b/tests/bunit.core.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensionsTest.cs
@@ -36,7 +36,7 @@ public void Test011()
var expected = Should.Throw(() =>
cut.WaitForAssertion(() => cut.Markup.ShouldBeEmpty(), TimeSpan.FromMilliseconds(10)));
- expected.Message.ShouldBe(WaitForAssertionHelper.TimeoutMessage);
+ expected.Message.ShouldStartWith(WaitForAssertionHelper.TimeoutMessage);
}
[Fact(DisplayName = "WaitForState throws exception after timeout")]
@@ -47,7 +47,7 @@ public void Test012()
var expected = Should.Throw(() =>
cut.WaitForState(() => string.IsNullOrEmpty(cut.Markup), TimeSpan.FromMilliseconds(100)));
- expected.Message.ShouldBe(WaitForStateHelper.TimeoutBeforePassMessage);
+ expected.Message.ShouldStartWith(WaitForStateHelper.TimeoutBeforePassMessage);
}
[Fact(DisplayName = "WaitForState throws exception if statePredicate throws on a later render")]
@@ -66,7 +66,7 @@ public void Test013()
return false;
}));
- expected.Message.ShouldBe(WaitForStateHelper.ExceptionInPredicateMessage);
+ expected.Message.ShouldStartWith(WaitForStateHelper.ExceptionInPredicateMessage);
expected.InnerException.ShouldBeOfType()
.Message.ShouldBe(expectedInnerMessage);
}
@@ -129,7 +129,7 @@ public void Test301()
() => cut.WaitForState(() => false, TimeSpan.FromSeconds(5)));
}
- internal class ThrowsAfterAsyncOperation : ComponentBase
+ private sealed class ThrowsAfterAsyncOperation : ComponentBase
{
protected override async Task OnInitializedAsync()
{
diff --git a/tests/bunit.core.tests/Rendering/RootRenderTreeTest.cs b/tests/bunit.core.tests/Rendering/RootRenderTreeTest.cs
index a7967c760..f874ee365 100644
--- a/tests/bunit.core.tests/Rendering/RootRenderTreeTest.cs
+++ b/tests/bunit.core.tests/Rendering/RootRenderTreeTest.cs
@@ -144,7 +144,7 @@ public void Test123()
x => x.ComponentType.ShouldBe(typeof(CascadingValue)));
}
- private class LayoutComponent : LayoutComponentBase
+ private sealed class LayoutComponent : LayoutComponentBase
{
[Parameter] public string Value { get; set; } = "LAYOUT VALUE";
[Parameter] public string? Name { get; set; }
@@ -160,7 +160,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
}
- private class InnerComponent : ComponentBase
+ private sealed class InnerComponent : ComponentBase
{
[CascadingParameter] public string LayoutValue { get; set; } = string.Empty;
@@ -172,7 +172,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
}
- private class MultipleParametersInnerComponent : ComponentBase
+ private sealed class MultipleParametersInnerComponent : ComponentBase
{
[CascadingParameter] public string StringValue { get; set; } = string.Empty;
[CascadingParameter] public int IntValue { get; set; }
diff --git a/tests/bunit.core.tests/Rendering/TestRendererTest.cs b/tests/bunit.core.tests/Rendering/TestRendererTest.cs
index bf26d6dc9..e447e9902 100644
--- a/tests/bunit.core.tests/Rendering/TestRendererTest.cs
+++ b/tests/bunit.core.tests/Rendering/TestRendererTest.cs
@@ -422,20 +422,20 @@ public void Test203()
Renderer.UnhandledException.Result.ShouldBeOfType();
}
- internal class NoChildNoParams : ComponentBase
+ internal sealed class NoChildNoParams : ComponentBase
{
public const string MARKUP = "hello world";
protected override void BuildRenderTree(RenderTreeBuilder builder) => builder.AddMarkupContent(0, MARKUP);
}
- internal class ThrowsDuringSetParams : ComponentBase
+ internal sealed class ThrowsDuringSetParams : ComponentBase
{
public static readonly InvalidOperationException EXCEPTION = new("THROWS ON PURPOSE");
public override Task SetParametersAsync(ParameterView parameters) => throw EXCEPTION;
}
- internal class HasParams : ComponentBase
+ internal sealed class HasParams : ComponentBase
{
[Parameter] public string? Value { get; set; }
[Parameter] public RenderFragment? ChildContent { get; set; }
@@ -447,7 +447,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
}
- internal class RenderTrigger : ComponentBase
+ internal sealed class RenderTrigger : ComponentBase
{
[Parameter] public string? Value { get; set; }
@@ -465,7 +465,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
}
- internal class ToggleChild : ComponentBase
+ internal sealed class ToggleChild : ComponentBase
{
private bool showing = true;
@@ -484,7 +484,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
}
- internal class SyncOperationThrows : ComponentBase
+ internal sealed class SyncOperationThrows : ComponentBase
{
public bool AwaitDone { get; private set; }
@@ -494,7 +494,7 @@ protected override void OnInitialized()
internal sealed class SyncOperationThrowsException : Exception { }
}
- internal class AsyncOperationThrows : ComponentBase
+ internal sealed class AsyncOperationThrows : ComponentBase
{
[Parameter] public Task Awaitable { get; set; }
@@ -506,7 +506,7 @@ protected override async Task OnInitializedAsync()
internal sealed class AsyncOperationThrowsException : Exception { }
}
- internal class AsyncAfterRenderThrows : ComponentBase
+ internal sealed class AsyncAfterRenderThrows : ComponentBase
{
[Inject] private IJSRuntime JSRuntime { get; set; }
diff --git a/tests/bunit.core.tests/TestContextBaseTest.net5.cs b/tests/bunit.core.tests/TestContextBaseTest.net5.cs
index 417156fa8..e077350ca 100644
--- a/tests/bunit.core.tests/TestContextBaseTest.net5.cs
+++ b/tests/bunit.core.tests/TestContextBaseTest.net5.cs
@@ -66,7 +66,7 @@ public async Task Test202()
DisposeComponents();
- await wasDisposedTask.ShouldCompleteWithin(TimeSpan.FromMilliseconds(100));
+ await wasDisposedTask.ShouldCompleteWithin(TimeSpan.FromSeconds(1));
}
[Fact(DisplayName = "DisposeComponents should dispose components added via ComponentFactory")]
diff --git a/tests/bunit.core.tests/TestServiceProviderTest.cs b/tests/bunit.core.tests/TestServiceProviderTest.cs
index 72bf94db8..047d3fc5d 100644
--- a/tests/bunit.core.tests/TestServiceProviderTest.cs
+++ b/tests/bunit.core.tests/TestServiceProviderTest.cs
@@ -264,30 +264,30 @@ public void Test037()
result.ShouldNotBeNull();
}
- private class DummyService { }
+ private sealed class DummyService { }
- private class AnotherDummyService { }
+ private sealed class AnotherDummyService { }
- private class OneMoreDummyService { }
+ private sealed class OneMoreDummyService { }
- private class DummyServiceWithDependencyOnAnotherDummyService
+ private sealed class DummyServiceWithDependencyOnAnotherDummyService
{
public DummyServiceWithDependencyOnAnotherDummyService(AnotherDummyService anotherDummyService)
{
}
}
- private class FallbackServiceProvider : IServiceProvider
+ private sealed class FallbackServiceProvider : IServiceProvider
{
public object GetService(Type serviceType) => new DummyService();
}
- private class AnotherFallbackServiceProvider : IServiceProvider
+ private sealed class AnotherFallbackServiceProvider : IServiceProvider
{
public object GetService(Type serviceType) => new AnotherDummyService();
}
- private class DummyComponentWhichRequiresDummyService : ComponentBase
+ private sealed class DummyComponentWhichRequiresDummyService : ComponentBase
{
[Inject] public DummyService Service { get; set; }
}
diff --git a/tests/bunit.testassets/AssertExtensions/TaskAssertionExtensions.cs b/tests/bunit.testassets/AssertExtensions/TaskAssertionExtensions.cs
index 934fc007a..63d4365b7 100644
--- a/tests/bunit.testassets/AssertExtensions/TaskAssertionExtensions.cs
+++ b/tests/bunit.testassets/AssertExtensions/TaskAssertionExtensions.cs
@@ -4,7 +4,15 @@ public static class TaskAssertionExtensions
{
public static async Task ShouldCompleteWithin(this Task task, TimeSpan timeout)
{
- if (task != await Task.WhenAny(task, Task.Delay(timeout)))
- throw new TimeoutException();
+#if NET6_0_OR_GREATER
+ await task.WaitAsync(timeout);
+#else
+ using var cts = new CancellationTokenSource();
+ var delayTask = Task.Delay(timeout, cts.Token);
+ if (task != await Task.WhenAny(task, delayTask))
+ throw new TimeoutException();
+
+ cts.Cancel();
+#endif
}
}
diff --git a/tests/bunit.testassets/Serilog.Sinks.XUnit/TestOutputSink.cs b/tests/bunit.testassets/Serilog.Sinks.XUnit/TestOutputSink.cs
index d46c19e51..e18364d0c 100644
--- a/tests/bunit.testassets/Serilog.Sinks.XUnit/TestOutputSink.cs
+++ b/tests/bunit.testassets/Serilog.Sinks.XUnit/TestOutputSink.cs
@@ -6,7 +6,7 @@
namespace Serilog.Sinks.XUnit;
-internal class TestOutputSink : ILogEventSink
+internal sealed class TestOutputSink : ILogEventSink
{
private readonly IMessageSink messageSink;
private readonly ITestOutputHelper testOutputHelper;
diff --git a/tests/bunit.testassets/ServiceCollectionLoggingExtensions.cs b/tests/bunit.testassets/ServiceCollectionLoggingExtensions.cs
index 25a5e0581..d469c62b0 100644
--- a/tests/bunit.testassets/ServiceCollectionLoggingExtensions.cs
+++ b/tests/bunit.testassets/ServiceCollectionLoggingExtensions.cs
@@ -18,7 +18,8 @@ public static IServiceCollection AddXunitLogger(this IServiceCollection services
.WriteTo.TestOutput(
testOutputHelper: outputHelper,
restrictedToMinimumLevel: LogEventLevel.Verbose,
- outputTemplate: ThreadIDEnricher.DefaultConsoleOutputTemplate)
+ outputTemplate: ThreadIDEnricher.DefaultConsoleOutputTemplate,
+ formatProvider: CultureInfo.InvariantCulture)
.CreateLogger();
services.AddSingleton(new LoggerFactory().AddSerilog(serilogLogger, dispose: true));
@@ -26,7 +27,7 @@ public static IServiceCollection AddXunitLogger(this IServiceCollection services
return services;
}
- private class ThreadIDEnricher : ILogEventEnricher
+ private sealed class ThreadIDEnricher : ILogEventEnricher
{
internal const string DefaultConsoleOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} ({ThreadID}) [{Level}] {Message}{NewLine}{Exception}";
diff --git a/tests/bunit.testassets/bunit.testassets.csproj b/tests/bunit.testassets/bunit.testassets.csproj
index 88a856ec5..11fd3f4d6 100644
--- a/tests/bunit.testassets/bunit.testassets.csproj
+++ b/tests/bunit.testassets/bunit.testassets.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/tests/bunit.web.testcomponents.tests/RazorTesting/FixtureBaseTest.cs b/tests/bunit.web.testcomponents.tests/RazorTesting/FixtureBaseTest.cs
index c8d50e9de..9eb35846f 100644
--- a/tests/bunit.web.testcomponents.tests/RazorTesting/FixtureBaseTest.cs
+++ b/tests/bunit.web.testcomponents.tests/RazorTesting/FixtureBaseTest.cs
@@ -2,7 +2,7 @@ namespace Bunit.RazorTesting;
public class FixtureBaseTest : TestContext
{
- private class FixtureComponent : FixtureBase
+ private sealed class FixtureComponent : FixtureBase
{
protected override Task RunAsync() => RunAsync(this);
}
diff --git a/tests/bunit.web.tests/BlazorE2E/ComponentRenderingTest.cs b/tests/bunit.web.tests/BlazorE2E/ComponentRenderingTest.cs
index 35b0dfce4..91182f2fb 100644
--- a/tests/bunit.web.tests/BlazorE2E/ComponentRenderingTest.cs
+++ b/tests/bunit.web.tests/BlazorE2E/ComponentRenderingTest.cs
@@ -544,7 +544,7 @@ public async Task CanAcceptSimultaneousRenderRequests()
await cut.WaitForAssertionAsync(
() => Assert.Equal(expectedOutput, outputElement.TextContent.Trim()),
- timeout: TimeSpan.FromMilliseconds(2000));
+ timeout: TimeSpan.FromSeconds(10));
}
[Fact]
@@ -565,7 +565,7 @@ public void CanAcceptSimultaneousRenderRequests_Sync()
cut.WaitForAssertion(
() => Assert.Equal(expectedOutput, outputElement.TextContent.Trim()),
- timeout: TimeSpan.FromMilliseconds(2000));
+ timeout: TimeSpan.FromSeconds(10));
}
[Fact]
diff --git a/tests/bunit.web.tests/ComponentFactories/StubComponentFactoryTest.cs b/tests/bunit.web.tests/ComponentFactories/StubComponentFactoryTest.cs
index 0249728c2..5bd566ce0 100644
--- a/tests/bunit.web.tests/ComponentFactories/StubComponentFactoryTest.cs
+++ b/tests/bunit.web.tests/ComponentFactories/StubComponentFactoryTest.cs
@@ -114,7 +114,7 @@ public void Test024(string randomText)
}
private class CompA : ComponentBase { }
- private class CompDerivedA : CompA { }
+ private sealed class CompDerivedA : CompA { }
}
#endif
diff --git a/tests/bunit.web.tests/Extensions/InputFile/InputFileTests.cs b/tests/bunit.web.tests/Extensions/InputFile/InputFileTests.cs
index 355e5677d..465813e21 100644
--- a/tests/bunit.web.tests/Extensions/InputFile/InputFileTests.cs
+++ b/tests/bunit.web.tests/Extensions/InputFile/InputFileTests.cs
@@ -103,7 +103,7 @@ public void Test008()
act.ShouldNotThrow();
}
- private class InputFileComponent : ComponentBase
+ private sealed class InputFileComponent : ComponentBase
{
public string? Filename { get; private set; }
public string? Content { get; private set; }
@@ -132,7 +132,7 @@ private void OnChange(InputFileChangeEventArgs args)
}
}
- private class MultipleInputFileComponent : ComponentBase
+ private sealed class MultipleInputFileComponent : ComponentBase
{
public readonly List Files = new();
@@ -158,7 +158,7 @@ private void OnChange(InputFileChangeEventArgs args)
}
}
- public record File(string Filename, string FileContent, DateTimeOffset LastChanged, long Size, string Type);
+ public sealed record File(string Filename, string FileContent, DateTimeOffset LastChanged, long Size, string Type);
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/tests/bunit.web.tests/Extensions/RefreshingWrappedElementTest.cs b/tests/bunit.web.tests/Extensions/RefreshingWrappedElementTest.cs
index 7d2475ade..d7fccaaf6 100644
--- a/tests/bunit.web.tests/Extensions/RefreshingWrappedElementTest.cs
+++ b/tests/bunit.web.tests/Extensions/RefreshingWrappedElementTest.cs
@@ -76,7 +76,7 @@ public void Test031()
Should.Throw(() => btn.TextContent);
}
- private class Markup : ComponentBase
+ private sealed class Markup : ComponentBase
{
[Parameter] public string Base { get; set; } = string.Empty;
[Parameter] public string? Optional { get; set; }
diff --git a/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensions.Async.Test.cs b/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensions.Async.Test.cs
index 27bce0034..c359b0eff 100644
--- a/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensions.Async.Test.cs
+++ b/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensions.Async.Test.cs
@@ -31,7 +31,7 @@ public async Task Test002()
var expected = await Should.ThrowAsync(async () =>
await cut.WaitForElementAsync("#notHereElm", TimeSpan.FromMilliseconds(10)));
- expected.Message.ShouldBe(WaitForElementHelper.TimeoutBeforeFoundMessage);
+ expected.Message.ShouldStartWith(WaitForElementHelper.TimeoutBeforeFoundMessage);
}
[Fact(DisplayName = "WaitForElements waits until cssSelector returns at least one element")]
@@ -55,7 +55,7 @@ public async Task Test022()
var expected = await Should.ThrowAsync(async () =>
await cut.WaitForElementsAsync("#notHereElm", TimeSpan.FromMilliseconds(30)));
- expected.Message.ShouldBe(WaitForElementsHelper.TimeoutBeforeFoundMessage);
+ expected.Message.ShouldStartWith(WaitForElementsHelper.TimeoutBeforeFoundMessage);
expected.InnerException.ShouldBeNull();
}
@@ -68,7 +68,7 @@ public async Task Test023()
var expected = await Should.ThrowAsync(async () =>
await cut.WaitForElementsAsync("#notHereElm", 2, TimeSpan.FromMilliseconds(30)));
- expected.Message.ShouldBe(string.Format(CultureInfo.InvariantCulture, WaitForElementsHelper.TimeoutBeforeFoundWithCountMessage, 2));
+ expected.Message.ShouldStartWith(string.Format(CultureInfo.InvariantCulture, WaitForElementsHelper.TimeoutBeforeFoundWithCountMessage, 2));
expected.InnerException.ShouldBeNull();
}
diff --git a/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensionsTest.cs b/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensionsTest.cs
index 936a39db3..5f03a60e3 100644
--- a/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensionsTest.cs
+++ b/tests/bunit.web.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForElementsHelperExtensionsTest.cs
@@ -31,7 +31,7 @@ public void Test002()
var expected = Should.Throw(() =>
cut.WaitForElement("#notHereElm", TimeSpan.FromMilliseconds(10)));
- expected.Message.ShouldBe(WaitForElementHelper.TimeoutBeforeFoundMessage);
+ expected.Message.ShouldStartWith(WaitForElementHelper.TimeoutBeforeFoundMessage);
}
[Fact(DisplayName = "WaitForElements waits until cssSelector returns at least one element")]
@@ -55,7 +55,7 @@ public void Test022()
var expected = Should.Throw(() =>
cut.WaitForElements("#notHereElm", TimeSpan.FromMilliseconds(30)));
- expected.Message.ShouldBe(WaitForElementsHelper.TimeoutBeforeFoundMessage);
+ expected.Message.ShouldStartWith(WaitForElementsHelper.TimeoutBeforeFoundMessage);
expected.InnerException.ShouldBeNull();
}
@@ -68,7 +68,7 @@ public void Test023()
var expected = Should.Throw(() =>
cut.WaitForElements("#notHereElm", 2, TimeSpan.FromMilliseconds(30)));
- expected.Message.ShouldBe(string.Format(CultureInfo.InvariantCulture, WaitForElementsHelper.TimeoutBeforeFoundWithCountMessage, 2));
+ expected.Message.ShouldStartWith(string.Format(CultureInfo.InvariantCulture, WaitForElementsHelper.TimeoutBeforeFoundWithCountMessage, 2));
expected.InnerException.ShouldBeNull();
}
diff --git a/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusAsyncInvocationHandlerTest.cs b/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusAsyncInvocationHandlerTest.cs
index b9103e89b..66b3aab95 100644
--- a/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusAsyncInvocationHandlerTest.cs
+++ b/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusAsyncInvocationHandlerTest.cs
@@ -38,7 +38,7 @@ public void Test003()
Assert.True(cut.Instance.AfterFirstRender);
}
- private class FocusingComponent : ComponentBase
+ private sealed class FocusingComponent : ComponentBase
{
private ElementReference elmRef;
internal bool AfterFirstRender { get; private set; }
diff --git a/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusOnNavigateHandlerTest.cs b/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusOnNavigateHandlerTest.cs
index a93bc4bfa..b6c3bc72f 100644
--- a/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusOnNavigateHandlerTest.cs
+++ b/tests/bunit.web.tests/JSInterop/InvocationHandlers/FocusOnNavigateHandlerTest.cs
@@ -43,7 +43,7 @@ public void Test002()
Assert.True(focusOnNavigateComponent.Instance.AfterFirstRender);
}
- private class FocusOnNavigateInternal : FocusOnNavigate
+ private sealed class FocusOnNavigateInternal : FocusOnNavigate
{
internal bool AfterFirstRender { get; private set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
diff --git a/tests/bunit.web.tests/Rendering/Internal/HtmlizerTests.cs b/tests/bunit.web.tests/Rendering/Internal/HtmlizerTests.cs
index 867d97b2c..d626b86a7 100644
--- a/tests/bunit.web.tests/Rendering/Internal/HtmlizerTests.cs
+++ b/tests/bunit.web.tests/Rendering/Internal/HtmlizerTests.cs
@@ -40,7 +40,7 @@ public void Test003()
cut.Find("button").HasAttribute("blazor:elementreference").ShouldBeTrue();
}
- private class Htmlizer01Component : ComponentBase
+ private sealed class Htmlizer01Component : ComponentBase
{
public ElementReference ButtomElmRef { get; set; }
diff --git a/tests/bunit.web.tests/TestContextTest.cs b/tests/bunit.web.tests/TestContextTest.cs
index 6d3f3fe3f..faa2fefa3 100644
--- a/tests/bunit.web.tests/TestContextTest.cs
+++ b/tests/bunit.web.tests/TestContextTest.cs
@@ -75,7 +75,7 @@ public void Test040()
Should.NotThrow(() => RenderComponent().Find("button").Click());
}
- private class ReceivesCascadingValue : ComponentBase
+ private sealed class ReceivesCascadingValue : ComponentBase
{
[CascadingParameter] public string? Value { get; set; }
diff --git a/tests/bunit.web.tests/TestDoubles/Components/ComponentDoubleBaseTest.cs b/tests/bunit.web.tests/TestDoubles/Components/ComponentDoubleBaseTest.cs
index cde222f8d..aeb80015b 100644
--- a/tests/bunit.web.tests/TestDoubles/Components/ComponentDoubleBaseTest.cs
+++ b/tests/bunit.web.tests/TestDoubles/Components/ComponentDoubleBaseTest.cs
@@ -3,7 +3,7 @@ namespace Bunit.TestDoubles.Components;
public class ComponentDoubleBaseTest : TestContext
{
- private class ComponentDouble : ComponentDoubleBase
+ private sealed class ComponentDouble : ComponentDoubleBase
where TComponent : IComponent
{ }
diff --git a/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs b/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs
index 68549436d..c51c5255c 100644
--- a/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs
+++ b/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs
@@ -263,7 +263,7 @@ public void Test015()
() => fakeNavigationManager.History.Last().StateFromJson());
}
- private class InterceptNavigateToCounterComponent : ComponentBase
+ private sealed class InterceptNavigateToCounterComponent : ComponentBase
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
@@ -293,7 +293,7 @@ private void InterceptNavigation(LocationChangingContext context)
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
}
- public class GotoExternalResourceComponent : ComponentBase
+ private sealed class GotoExternalResourceComponent : ComponentBase
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
@@ -312,7 +312,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
}
- private class ThrowsExceptionInInterceptNavigationComponent : ComponentBase
+ private sealed class ThrowsExceptionInInterceptNavigationComponent : ComponentBase
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
diff --git a/version.json b/version.json
index d3e1d4c1f..ada7dbd6a 100644
--- a/version.json
+++ b/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
- "version": "1.12",
+ "version": "1.13",
"assemblyVersion": {
"precision": "revision"
},