diff --git a/Directory.Packages.props b/Directory.Packages.props index d9524dcef..7c79b36a3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/tests/bunit.core.tests/Rendering/RenderModeTests.razor b/tests/bunit.core.tests/Rendering/RenderModeTests.razor index 0bded05f6..557b3386e 100644 --- a/tests/bunit.core.tests/Rendering/RenderModeTests.razor +++ b/tests/bunit.core.tests/Rendering/RenderModeTests.razor @@ -168,7 +168,7 @@ ); - act.ShouldThrow(); // todo: figure out good exception to use + act.ShouldThrow(); } } @code{ diff --git a/tests/bunit.core.tests/TestDoubles/PersistentComponentState/FakePersistentComponentStateTest.cs b/tests/bunit.core.tests/TestDoubles/PersistentComponentState/FakePersistentComponentStateTest.cs index cb3d256a2..f54aa345c 100644 --- a/tests/bunit.core.tests/TestDoubles/PersistentComponentState/FakePersistentComponentStateTest.cs +++ b/tests/bunit.core.tests/TestDoubles/PersistentComponentState/FakePersistentComponentStateTest.cs @@ -67,7 +67,7 @@ public void Test013(string key) { var fakeState = this.AddFakePersistentComponentState(); - fakeState.TryTake(key, out var actual).ShouldBeFalse(); + fakeState.TryTake(key, out _).ShouldBeFalse(); } [Fact(DisplayName = "TriggerOnPersisting triggers OnPersisting callbacks added to store")] diff --git a/tests/bunit.testassets/BlazorE2E/AddRemoveChildComponents.razor b/tests/bunit.testassets/BlazorE2E/AddRemoveChildComponents.razor index 1c05a7166..ba4bca194 100644 --- a/tests/bunit.testassets/BlazorE2E/AddRemoveChildComponents.razor +++ b/tests/bunit.testassets/BlazorE2E/AddRemoveChildComponents.razor @@ -10,7 +10,7 @@ Child components follow. @code { int numAdded = 0; - List currentChildrenMessages = new List(); + private readonly List currentChildrenMessages = new List(); void AddChild() { diff --git a/tests/bunit.testassets/BlazorE2E/DataDashComponent.razor b/tests/bunit.testassets/BlazorE2E/DataDashComponent.razor index 435ef0fc0..06567bb4a 100644 --- a/tests/bunit.testassets/BlazorE2E/DataDashComponent.razor +++ b/tests/bunit.testassets/BlazorE2E/DataDashComponent.razor @@ -1,5 +1,5 @@ @TabId @code { - string TabId = "17"; + private readonly string TabId = "17"; } diff --git a/tests/bunit.testassets/BlazorE2E/DuplicateAttributesComponent.razor b/tests/bunit.testassets/BlazorE2E/DuplicateAttributesComponent.razor index 20899324f..837da0f95 100644 --- a/tests/bunit.testassets/BlazorE2E/DuplicateAttributesComponent.razor +++ b/tests/bunit.testassets/BlazorE2E/DuplicateAttributesComponent.razor @@ -13,7 +13,7 @@ @functions { - Dictionary elementValues = new Dictionary + private readonly Dictionary elementValues = new Dictionary { { "bool", true }, { "string", "middle-value" }, diff --git a/tests/bunit.testassets/BlazorE2E/KeyPressEventComponent.razor b/tests/bunit.testassets/BlazorE2E/KeyPressEventComponent.razor index dd96e41d5..d5931408d 100644 --- a/tests/bunit.testassets/BlazorE2E/KeyPressEventComponent.razor +++ b/tests/bunit.testassets/BlazorE2E/KeyPressEventComponent.razor @@ -9,7 +9,7 @@ Type here: @code { - List keysPressed = new List(); + private readonly List keysPressed = new List(); void OnKeyPressed(KeyboardEventArgs eventArgs) { diff --git a/tests/bunit.testassets/BlazorE2E/MarkupBlockComponent.razor b/tests/bunit.testassets/BlazorE2E/MarkupBlockComponent.razor index ee7f9a185..1b9597319 100644 --- a/tests/bunit.testassets/BlazorE2E/MarkupBlockComponent.razor +++ b/tests/bunit.testassets/BlazorE2E/MarkupBlockComponent.razor @@ -28,7 +28,7 @@ #nullable disable bool changeOutput; - string myMarkup = "This is a markup string."; + private readonly string myMarkup = "This is a markup string."; void EmitMarkupBlock(RenderTreeBuilder builder) { diff --git a/tests/bunit.testassets/BlazorE2E/MovingCheckboxesComponent.razor b/tests/bunit.testassets/BlazorE2E/MovingCheckboxesComponent.razor index fbb1f4cf5..872b35bc2 100644 --- a/tests/bunit.testassets/BlazorE2E/MovingCheckboxesComponent.razor +++ b/tests/bunit.testassets/BlazorE2E/MovingCheckboxesComponent.razor @@ -41,7 +41,7 @@ @code { #nullable disable - List items = new List + private readonly List items = new List { new TodoItem { Text = "Alpha" }, new TodoItem { Text = "Beta" }, @@ -49,7 +49,7 @@ new TodoItem { Text = "Delta", IsDone = true }, }; - class TodoItem + private sealed class TodoItem { public bool IsDone { get; set; } public string Text { get; set; } diff --git a/tests/bunit.testassets/BlazorE2E/OrderedList.razor b/tests/bunit.testassets/BlazorE2E/OrderedList.razor index 96130629b..f7a712635 100644 --- a/tests/bunit.testassets/BlazorE2E/OrderedList.razor +++ b/tests/bunit.testassets/BlazorE2E/OrderedList.razor @@ -6,7 +6,7 @@ } @foreach (var item in Items) { - @Template(new Context { Index = index++, Item = item, }); + @Template(new Context { Index = index++, Item = item, }) } diff --git a/tests/bunit.testassets/SampleComponents/AsyncRenderChangesProperty.razor b/tests/bunit.testassets/SampleComponents/AsyncRenderChangesProperty.razor index e4368832a..4e68b7eb6 100644 --- a/tests/bunit.testassets/SampleComponents/AsyncRenderChangesProperty.razor +++ b/tests/bunit.testassets/SampleComponents/AsyncRenderChangesProperty.razor @@ -1,7 +1,7 @@ Tick Tock @code { - private TaskCompletionSource _tcs = new TaskCompletionSource(); + private readonly TaskCompletionSource _tcs = new TaskCompletionSource(); public int Counter; private Task Tick() diff --git a/tests/bunit.testassets/SampleComponents/InvokeAsyncInsideContinueWith.razor b/tests/bunit.testassets/SampleComponents/InvokeAsyncInsideContinueWith.razor index 9be4161b2..1abdf2cd8 100644 --- a/tests/bunit.testassets/SampleComponents/InvokeAsyncInsideContinueWith.razor +++ b/tests/bunit.testassets/SampleComponents/InvokeAsyncInsideContinueWith.razor @@ -22,13 +22,13 @@ { registeredTask = task; delegatedTask = task == null ? null : DelegateTo(task); - RenderWhenDone(); + _ = RenderWhenDone(); } base.OnParametersSet(); } - private async void RenderWhenDone() + private async Task RenderWhenDone() { var task = delegatedTask; if (task != null) @@ -44,7 +44,7 @@ private static async Task DelegateTo(Task task) { - await task;//.ConfigureAwait(false); + await task; return null; } } diff --git a/tests/bunit.testassets/SampleComponents/RenderOnClick.razor b/tests/bunit.testassets/SampleComponents/RenderOnClick.razor index d5ed71b16..b42b04388 100644 --- a/tests/bunit.testassets/SampleComponents/RenderOnClick.razor +++ b/tests/bunit.testassets/SampleComponents/RenderOnClick.razor @@ -2,8 +2,11 @@ @code { public int RenderCount { get; private set; } - - void IncreaseCount() { } + + void IncreaseCount() + { + // Left empty on purpose + } protected override void OnAfterRender(bool firstRender) => RenderCount++; } \ No newline at end of file diff --git a/tests/bunit.testassets/SampleComponents/SimpleUsingLocalizer.razor b/tests/bunit.testassets/SampleComponents/SimpleUsingLocalizer.razor index 9992ee117..d077d54b0 100644 --- a/tests/bunit.testassets/SampleComponents/SimpleUsingLocalizer.razor +++ b/tests/bunit.testassets/SampleComponents/SimpleUsingLocalizer.razor @@ -6,7 +6,7 @@ @code { protected override void OnInitialized() { - var localizedString = StringLocalizer["StringName"]; + _ = StringLocalizer["StringName"]; } } diff --git a/tests/bunit.testassets/SampleComponents/SimpleWithTemplate.razor b/tests/bunit.testassets/SampleComponents/SimpleWithTemplate.razor index 0ba4abec3..700fcdc83 100644 --- a/tests/bunit.testassets/SampleComponents/SimpleWithTemplate.razor +++ b/tests/bunit.testassets/SampleComponents/SimpleWithTemplate.razor @@ -1,7 +1,7 @@ @typeparam T @foreach (var d in Data) { - @Template?.Invoke(d); + @Template?.Invoke(d) } @code { diff --git a/tests/bunit.testassets/SampleComponents/ToggleableDetails.razor b/tests/bunit.testassets/SampleComponents/ToggleableDetails.razor index 5dcb306e3..b1cf9da25 100644 --- a/tests/bunit.testassets/SampleComponents/ToggleableDetails.razor +++ b/tests/bunit.testassets/SampleComponents/ToggleableDetails.razor @@ -3,7 +3,7 @@ { Read the details carefully! } - + Summary Detailed content diff --git a/tests/bunit.web.tests/Asserting/MarkupMatchesTests.razor b/tests/bunit.web.tests/Asserting/MarkupMatchesTests.razor index d8723291f..d4b3bf5c4 100644 --- a/tests/bunit.web.tests/Asserting/MarkupMatchesTests.razor +++ b/tests/bunit.web.tests/Asserting/MarkupMatchesTests.razor @@ -1,13 +1,9 @@ -@using Bunit.TestAssets @using Bunit.TestAssets.SampleComponents @inherits TestContext @code { - private readonly ITestOutputHelper outputHelper; - - public MarkupMatchesTests(ITestOutputHelper outputHelper) + public MarkupMatchesTests() { - this.outputHelper = outputHelper; - TestContext.DefaultWaitTimeout = TimeSpan.FromSeconds(30); + DefaultWaitTimeout = TimeSpan.FromSeconds(30); } [Fact]
This is a markup string.
Read the details carefully!
Detailed content