Use TestContext as base class for Passing parameters to components#1034
Use TestContext as base class for Passing parameters to components#1034
Conversation
egil
left a comment
There was a problem hiding this comment.
Awesome, think the number of issues and questions we are seeing makes this a good change.
|
Should I also "refactor" the other tests in this PR or do we want to do this later? |
Let's get all examples converted. I also think we should consider expanded the included lines in each example such that they show we are inheriting. |
Understood - I will ping when I am done. Will do some smaller commits as I have to sync between my Mac and Windows and stuff. |
|
So I refactored all the code examples to use the I would advise that you check out the branch locally and check with docfx - I do think I hit everything, but 4 eyes are better. |
|
Thanks Steven. I'll check tomorrow. Had a day of travels. |
|
I spotted a few things I wanted to change and have pushed a PR. There are a few other places where I saw some inconsistencies with indention (in the code in docs its 2 spaces instead of a tab, as we use in the code). On the "writing a test" page, should the NUnit and MSTest samples also be upgraded to use the inheriting trick? |
Darn. I'll have a look later. Yeah Rider probably formats on save and for some reasons ignores the |
|
Oh I found out why: our |
|
Pushed the indentation stuff to 2 - also updated editorconfig files as well as some examples in nunit/msunit |
|
Changed the wording on getting started again, and updated index too. Please look through those pages and let me know what you think. |
|
Currently only limited to my mobile as I am on a short vacation so did. only had s short look, but looked good 👍 |
…nts (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk>
…nts (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk>
* docs: Use TestContext as base class for Passing parameters to components (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: broken sample code * doc: fixes to sample code to make it compile * docs: added CounterTest.razor * docs: fix code references, added missing samples * docs: change code ref to correct type --------- Co-authored-by: Egil Hansen <egil@assimilated.dk>
* build(deps): Bump SonarAnalyzer.CSharp from 8.51.0.59060 to 8.52.0.60960 Bumps [SonarAnalyzer.CSharp](https://github.com/SonarSource/sonar-dotnet) from 8.51.0.59060 to 8.52.0.60960. - [Release notes](https://github.com/SonarSource/sonar-dotnet/releases) - [Commits](SonarSource/sonar-dotnet@8.51.0.59060...8.52.0.60960) --- updated-dependencies: - dependency-name: SonarAnalyzer.CSharp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build: set AccelerateBuildsInVisualStudio to true * chore: upgrade anglesharp.diffing to 0.17.1 * docs: update changelog * Revert AngleSharp from 1.0.1 to 0.17.1 This reverts commit 8ac537a. # Conflicts: # src/AngleSharpWrappers/AngleSharpWrappers.csproj # src/bunit.web/bunit.web.csproj * Set version to '1.15' * Set version to '1.16-preview' * Updated CHANGELOG.md for 1.15.5 release * fix: allow semantic comparer to compare IHtmlUnknownElement types * Set version to '1.16' * Set version to '1.17-preview' * Updated CHANGELOG.md for 1.16.2 release * fix: wrong type assignment in doc (#975) * refactor: Use PackageOutputPath instead of -o * build(deps): Bump System.Text.Json from 7.0.1 to 7.0.2 Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 7.0.1 to 7.0.2. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](dotnet/runtime@v7.0.1...v7.0.2) --- updated-dependencies: - dependency-name: System.Text.Json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Honor preventdefault for events so they don't bubble (#982) * Honor preventdefault for events so they don't bubble * Small change to fix the normal bubbling events * Small rename of a private method to better indicate its intention * Improvement and simplification * Build fix by removing an empty statement * Changelog * formatting of the changelog * Updated changelog --------- Co-authored-by: Steven Giesel <stgiesel35@gmail.com> * build(deps): Bump BenchmarkDotNet from 0.13.4 to 0.13.5 Bumps [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) from 0.13.4 to 0.13.5. - [Release notes](https://github.com/dotnet/BenchmarkDotNet/releases) - [Commits](dotnet/BenchmarkDotNet@v0.13.4...v0.13.5) --- updated-dependencies: - dependency-name: BenchmarkDotNet dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Set version to '1.17' * Set version to '1.18-preview' * Updated CHANGELOG.md for 1.17.2 release * build(deps): Bump AutoFixture from 4.17.0 to 4.18.0 Bumps [AutoFixture](https://github.com/AutoFixture/AutoFixture) from 4.17.0 to 4.18.0. - [Release notes](https://github.com/AutoFixture/AutoFixture/releases) - [Commits](AutoFixture/AutoFixture@v4.17.0...v4.18.0) --- updated-dependencies: - dependency-name: AutoFixture dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump AutoFixture.Xunit2 from 4.17.0 to 4.18.0 Bumps [AutoFixture.Xunit2](https://github.com/AutoFixture/AutoFixture) from 4.17.0 to 4.18.0. - [Release notes](https://github.com/AutoFixture/AutoFixture/releases) - [Commits](AutoFixture/AutoFixture@v4.17.0...v4.18.0) --- updated-dependencies: - dependency-name: AutoFixture.Xunit2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump Microsoft.NET.Test.Sdk from 17.4.1 to 17.5.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.4.1 to 17.5.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](microsoft/vstest@v17.4.1...v17.5.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: Escape text inside html tag and attributes * fix: Added tests for escpable characters * fix: Escape text inside html tag * Added changelog entry * chore: code cleanup * fix: optimize char replacement --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * build(deps): Bump SonarAnalyzer.CSharp from 8.52.0.60960 to 8.53.0.62665 (#988) * build(deps): Bump SonarAnalyzer.CSharp from 8.52.0.60960 to 8.53.0.62665 Bumps [SonarAnalyzer.CSharp](https://github.com/SonarSource/sonar-dotnet) from 8.52.0.60960 to 8.53.0.62665. - [Release notes](https://github.com/SonarSource/sonar-dotnet/releases) - [Commits](SonarSource/sonar-dotnet@8.52.0.60960...8.53.0.62665) --- updated-dependencies: - dependency-name: SonarAnalyzer.CSharp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * chore: code analyzer rules code updates --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Egil Hansen <egil@assimilated.dk> * fix: submit button/input element submits form (#1000) * fix: submit button/input element submits form * handle other edge cases * code clean up * simplify conditionals * Set version to '1.18' * Set version to '1.19-preview' * Updated CHANGELOG.md for 1.18.4 release * chore: use file scoped namespaces * Simplify null coalescing * refactor: use early return and simplify call * fix(nullable): forward nullability correctly (#1013) * fix(nullable): forward nullability correctly * Update src/bunit.web/TestContext.cs Co-authored-by: Egil Hansen <egil@assimilated.dk> --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: improve examples of semantic comparison modifiers * build(deps): Bump AngleSharp.Diffing from 0.17.1 to 0.18.1 Bumps [AngleSharp.Diffing](https://github.com/AngleSharp/AngleSharp.Diffing) from 0.17.1 to 0.18.1. - [Release notes](https://github.com/AngleSharp/AngleSharp.Diffing/releases) - [Changelog](https://github.com/AngleSharp/AngleSharp.Diffing/blob/devel/CHANGELOG.md) - [Commits](AngleSharp/AngleSharp.Diffing@v0.17.1...v0.18.1) --- updated-dependencies: - dependency-name: AngleSharp.Diffing dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * docs: Use TestContext as base class for Passing parameters to components (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: broken sample code * doc: fixes to sample code to make it compile * docs: added CounterTest.razor * docs: fix code references, added missing samples * docs: Use TestContext as base class for Passing parameters to components (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: broken sample code * doc: fixes to sample code to make it compile * docs: added CounterTest.razor * docs: fix code references, added missing samples * docs: change code ref to correct type * chore: code clean up * fix: clean up tests * fix: run markup updates in users sync context * fix: synchronize code that reads/writes to the internal render tree in TestRenderer/Renderer * build(deps): Bump SonarAnalyzer.CSharp from 8.54.0.63966 to 8.56.0.67649 Bumps [SonarAnalyzer.CSharp](https://github.com/SonarSource/sonar-dotnet) from 8.54.0.63966 to 8.56.0.67649. - [Release notes](https://github.com/SonarSource/sonar-dotnet/releases) - [Commits](https://github.com/SonarSource/sonar-dotnet/commits/8.56.0.67649) --- updated-dependencies: - dependency-name: SonarAnalyzer.CSharp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump dotnet-serve from 1.7.125 to 1.10.155 Bumps [dotnet-serve](https://github.com/natemcmaster/dotnet-serve) from 1.7.125 to 1.10.155. - [Release notes](https://github.com/natemcmaster/dotnet-serve/releases) - [Commits](https://github.com/natemcmaster/dotnet-serve/commits/v1.10.155) --- updated-dependencies: - dependency-name: dotnet-serve dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: Custom elements with attributes throw exception * fix: Better naming for test method (#1048) * fix: Better naming for test method * fix: Don't use unknown matcher first * fix: Don't use unknown matcher first * Add attribute * Merge stable into main (#1050) * docs: Use TestContext as base class for Passing parameters to components (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: broken sample code * doc: fixes to sample code to make it compile * docs: added CounterTest.razor * docs: fix code references, added missing samples * docs: change code ref to correct type --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * Set version to '1.19' * Set version to '1.20-preview' * Updated CHANGELOG.md for 1.19.14 release * Update to net8.0 * Remove preprocessor directives * Wave 2 * Remove net60 dep in test * More changes * Bump actions --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Egil Hansen <egil@assimilated.dk> Co-authored-by: bUnit bot <bot@bunit.dev> Co-authored-by: JelleHissink <Jelle@CodeWise.nl> Co-authored-by: Florian Dohrendorf <LunicLynx@users.noreply.github.com>
* build(deps): Bump SonarAnalyzer.CSharp from 8.51.0.59060 to 8.52.0.60960 Bumps [SonarAnalyzer.CSharp](https://github.com/SonarSource/sonar-dotnet) from 8.51.0.59060 to 8.52.0.60960. - [Release notes](https://github.com/SonarSource/sonar-dotnet/releases) - [Commits](SonarSource/sonar-dotnet@8.51.0.59060...8.52.0.60960) --- updated-dependencies: - dependency-name: SonarAnalyzer.CSharp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build: set AccelerateBuildsInVisualStudio to true * chore: upgrade anglesharp.diffing to 0.17.1 * docs: update changelog * Revert AngleSharp from 1.0.1 to 0.17.1 This reverts commit 8ac537a. # Conflicts: # src/AngleSharpWrappers/AngleSharpWrappers.csproj # src/bunit.web/bunit.web.csproj * Set version to '1.15' * Set version to '1.16-preview' * Updated CHANGELOG.md for 1.15.5 release * fix: allow semantic comparer to compare IHtmlUnknownElement types * Set version to '1.16' * Set version to '1.17-preview' * Updated CHANGELOG.md for 1.16.2 release * fix: wrong type assignment in doc (#975) * refactor: Use PackageOutputPath instead of -o * build(deps): Bump System.Text.Json from 7.0.1 to 7.0.2 Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 7.0.1 to 7.0.2. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](dotnet/runtime@v7.0.1...v7.0.2) --- updated-dependencies: - dependency-name: System.Text.Json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Honor preventdefault for events so they don't bubble (#982) * Honor preventdefault for events so they don't bubble * Small change to fix the normal bubbling events * Small rename of a private method to better indicate its intention * Improvement and simplification * Build fix by removing an empty statement * Changelog * formatting of the changelog * Updated changelog --------- Co-authored-by: Steven Giesel <stgiesel35@gmail.com> * build(deps): Bump BenchmarkDotNet from 0.13.4 to 0.13.5 Bumps [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) from 0.13.4 to 0.13.5. - [Release notes](https://github.com/dotnet/BenchmarkDotNet/releases) - [Commits](dotnet/BenchmarkDotNet@v0.13.4...v0.13.5) --- updated-dependencies: - dependency-name: BenchmarkDotNet dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Set version to '1.17' * Set version to '1.18-preview' * Updated CHANGELOG.md for 1.17.2 release * build(deps): Bump AutoFixture from 4.17.0 to 4.18.0 Bumps [AutoFixture](https://github.com/AutoFixture/AutoFixture) from 4.17.0 to 4.18.0. - [Release notes](https://github.com/AutoFixture/AutoFixture/releases) - [Commits](AutoFixture/AutoFixture@v4.17.0...v4.18.0) --- updated-dependencies: - dependency-name: AutoFixture dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump AutoFixture.Xunit2 from 4.17.0 to 4.18.0 Bumps [AutoFixture.Xunit2](https://github.com/AutoFixture/AutoFixture) from 4.17.0 to 4.18.0. - [Release notes](https://github.com/AutoFixture/AutoFixture/releases) - [Commits](AutoFixture/AutoFixture@v4.17.0...v4.18.0) --- updated-dependencies: - dependency-name: AutoFixture.Xunit2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump Microsoft.NET.Test.Sdk from 17.4.1 to 17.5.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.4.1 to 17.5.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](microsoft/vstest@v17.4.1...v17.5.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: Escape text inside html tag and attributes * fix: Added tests for escpable characters * fix: Escape text inside html tag * Added changelog entry * chore: code cleanup * fix: optimize char replacement --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * build(deps): Bump SonarAnalyzer.CSharp from 8.52.0.60960 to 8.53.0.62665 (#988) * build(deps): Bump SonarAnalyzer.CSharp from 8.52.0.60960 to 8.53.0.62665 Bumps [SonarAnalyzer.CSharp](https://github.com/SonarSource/sonar-dotnet) from 8.52.0.60960 to 8.53.0.62665. - [Release notes](https://github.com/SonarSource/sonar-dotnet/releases) - [Commits](SonarSource/sonar-dotnet@8.52.0.60960...8.53.0.62665) --- updated-dependencies: - dependency-name: SonarAnalyzer.CSharp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * chore: code analyzer rules code updates --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Egil Hansen <egil@assimilated.dk> * fix: submit button/input element submits form (#1000) * fix: submit button/input element submits form * handle other edge cases * code clean up * simplify conditionals * Set version to '1.18' * Set version to '1.19-preview' * Updated CHANGELOG.md for 1.18.4 release * chore: use file scoped namespaces * Simplify null coalescing * refactor: use early return and simplify call * fix(nullable): forward nullability correctly (#1013) * fix(nullable): forward nullability correctly * Update src/bunit.web/TestContext.cs Co-authored-by: Egil Hansen <egil@assimilated.dk> --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: improve examples of semantic comparison modifiers * build(deps): Bump AngleSharp.Diffing from 0.17.1 to 0.18.1 Bumps [AngleSharp.Diffing](https://github.com/AngleSharp/AngleSharp.Diffing) from 0.17.1 to 0.18.1. - [Release notes](https://github.com/AngleSharp/AngleSharp.Diffing/releases) - [Changelog](https://github.com/AngleSharp/AngleSharp.Diffing/blob/devel/CHANGELOG.md) - [Commits](AngleSharp/AngleSharp.Diffing@v0.17.1...v0.18.1) --- updated-dependencies: - dependency-name: AngleSharp.Diffing dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * docs: Use TestContext as base class for Passing parameters to components (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: broken sample code * doc: fixes to sample code to make it compile * docs: added CounterTest.razor * docs: fix code references, added missing samples * docs: Use TestContext as base class for Passing parameters to components (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: broken sample code * doc: fixes to sample code to make it compile * docs: added CounterTest.razor * docs: fix code references, added missing samples * docs: change code ref to correct type * chore: code clean up * fix: clean up tests * fix: run markup updates in users sync context * fix: synchronize code that reads/writes to the internal render tree in TestRenderer/Renderer * build(deps): Bump SonarAnalyzer.CSharp from 8.54.0.63966 to 8.56.0.67649 Bumps [SonarAnalyzer.CSharp](https://github.com/SonarSource/sonar-dotnet) from 8.54.0.63966 to 8.56.0.67649. - [Release notes](https://github.com/SonarSource/sonar-dotnet/releases) - [Commits](https://github.com/SonarSource/sonar-dotnet/commits/8.56.0.67649) --- updated-dependencies: - dependency-name: SonarAnalyzer.CSharp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump dotnet-serve from 1.7.125 to 1.10.155 Bumps [dotnet-serve](https://github.com/natemcmaster/dotnet-serve) from 1.7.125 to 1.10.155. - [Release notes](https://github.com/natemcmaster/dotnet-serve/releases) - [Commits](https://github.com/natemcmaster/dotnet-serve/commits/v1.10.155) --- updated-dependencies: - dependency-name: dotnet-serve dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: Custom elements with attributes throw exception * fix: Better naming for test method (#1048) * fix: Better naming for test method * fix: Don't use unknown matcher first * fix: Don't use unknown matcher first * Add attribute * Merge stable into main (#1050) * docs: Use TestContext as base class for Passing parameters to components (#1034) * refactor: Use TestContext as base class * fixes to docs * Indent size 2 * fix getting started and index --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * docs: broken sample code * doc: fixes to sample code to make it compile * docs: added CounterTest.razor * docs: fix code references, added missing samples * docs: change code ref to correct type --------- Co-authored-by: Egil Hansen <egil@assimilated.dk> * Set version to '1.19' * Set version to '1.20-preview' * Updated CHANGELOG.md for 1.19.14 release * Update to net8.0 * Remove preprocessor directives * Wave 2 * Remove net60 dep in test * More changes * Bump actions --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Egil Hansen <egil@assimilated.dk> Co-authored-by: bUnit bot <bot@bunit.dev> Co-authored-by: JelleHissink <Jelle@CodeWise.nl> Co-authored-by: Florian Dohrendorf <LunicLynx@users.noreply.github.com>
For the whole section of "Passing parameters to components" I used the
TestContextas a base class and not instantiating a new one on every test.This is anyway the recommended way - I added that that in the beginning as well.
I also used file-scoped namespaces in the regular plain old c# tests.
Edit: We can make this the defacto standard for every documentation if you wish and showing only one example how to instantiate a new
TestContextjust to be complete.