diff --git a/CHANGELOG.md b/CHANGELOG.md index f0745dfbc..c180547af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,13 @@ All notable changes to **bUnit** will be documented in this file. The project ad ## [Unreleased] +## [1.39.5] - 2025-04-04 + ### Fixed - Do not set the `Uri` or `BaseUri` property on the `FakeNavigationManager` if navigation is prevented by a handler on `net7.0` or greater. Reported and fixed by [@ayyron-dev](https://github.com/ayyron-dev) in [#1647](https://github.com/bUnit-dev/bUnit/issues/1647) +- Use default renderer properties for AngleSharp. Reported by [@jtleaming](https://github.com/jtleaming) in [#1692]. +- `FindComponents` throws an exception, when a base and derived class was searched for. Reported by [@BlueDragon709](https://github.com/BlueDragon709) in [#1691]. ## [1.38.5] - 2025-01-12 @@ -1443,7 +1447,8 @@ The latest version of the library is availble on NuGet: - **Wrong casing on keyboard event dispatch helpers.** The helper methods for the keyboard events was not probably cased, so that has been updated. E.g. from `Keypress(...)` to `KeyPress(...)`. -[unreleased]: https://github.com/bUnit-dev/bUnit/compare/v1.38.5...HEAD +[unreleased]: https://github.com/bUnit-dev/bUnit/compare/v1.39.5...HEAD +[1.39.5]: https://github.com/bUnit-dev/bUnit/compare/v1.38.5...1.39.5 [1.38.5]: https://github.com/bUnit-dev/bUnit/compare/v1.37.7...v1.38.5 [1.37.7]: https://github.com/bUnit-dev/bUnit/compare/v1.36.0...1.37.7 [1.36.0]: https://github.com/bUnit-dev/bUnit/compare/v1.35.3...v1.36.0 diff --git a/README.md b/README.md index 5c3d70e75..e141b15ed 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/egil). T
- + @syncfusion
Syncfusion diff --git a/docs/site/docs/verification/semantic-html-comparison.md b/docs/site/docs/verification/semantic-html-comparison.md index 38fe3b5f2..939e490f2 100644 --- a/docs/site/docs/verification/semantic-html-comparison.md +++ b/docs/site/docs/verification/semantic-html-comparison.md @@ -105,7 +105,7 @@ Here are the customization options you have available to you: ```html

HeLLo world

-
``` To perform case insensitive comparison of the text inside the `id` attribute, do the following: diff --git a/docs/site/index.md b/docs/site/index.md index 9d0242daa..c10804d1e 100644 --- a/docs/site/index.md +++ b/docs/site/index.md @@ -53,11 +53,16 @@ bUnit is available on NuGet in various incarnations. Most users should just pick A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/egil). The higher tier sponsors are:
## Contributors diff --git a/src/bunit/Rendering/BunitHtmlParser.cs b/src/bunit/Rendering/BunitHtmlParser.cs index c2a41e18b..652f69984 100644 --- a/src/bunit/Rendering/BunitHtmlParser.cs +++ b/src/bunit/Rendering/BunitHtmlParser.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Diagnostics; using AngleSharp; +using AngleSharp.Css; using AngleSharp.Dom; using AngleSharp.Html.Parser; using Bunit.Diffing; @@ -28,7 +29,8 @@ public sealed class BunitHtmlParser : IDisposable /// with a AngleSharp context without a registered. /// public BunitHtmlParser() - : this(Configuration.Default.WithCss().With(new HtmlComparer())) { } + : this(Configuration.Default.WithCss() + .With(new HtmlComparer())) { } /// /// Initializes a new instance of the class @@ -43,7 +45,13 @@ public BunitHtmlParser(HtmlComparer htmlComparer, BunitContext bunitContext) private BunitHtmlParser(IConfiguration angleSharpConfiguration) { - var config = angleSharpConfiguration.With(this); + var config = angleSharpConfiguration + .With(this) + .WithRenderDevice(new DefaultRenderDevice + { + ViewPortWidth = 1920, + ViewPortHeight = 1080, + }); context = BrowsingContext.New(config); var parseOptions = new HtmlParserOptions { diff --git a/src/bunit/Rendering/BunitRenderer.cs b/src/bunit/Rendering/BunitRenderer.cs index 88d87c47e..46c0ed095 100644 --- a/src/bunit/Rendering/BunitRenderer.cs +++ b/src/bunit/Rendering/BunitRenderer.cs @@ -634,40 +634,6 @@ private IRenderedComponent GetRenderedComponent(int comp return (IRenderedComponent)result; } - /// - /// Populates the with - /// starting with the one that belongs to the component with ID . - /// - private void LoadRenderTreeFrames(int componentId, RenderTreeFrameDictionary framesCollection) - { - var frames = GetOrLoadRenderTreeFrame(framesCollection, componentId); - - for (var i = 0; i < frames.Count; i++) - { - ref var frame = ref frames.Array[i]; - - if (frame.FrameType == RenderTreeFrameType.Component && !framesCollection.Contains(frame.ComponentId)) - { - LoadRenderTreeFrames(frame.ComponentId, framesCollection); - } - } - } - - /// - /// Gets the from the . - /// If the does not contain the frames, they are loaded into it first. - /// - private ArrayRange GetOrLoadRenderTreeFrame(RenderTreeFrameDictionary framesCollection, int componentId) - { - if (!framesCollection.TryGetValue(componentId, out var frames)) - { - frames = GetCurrentRenderTreeFrames(componentId); - framesCollection.Add(componentId, frames); - } - - return frames; - } - /// protected override void HandleException(Exception exception) { diff --git a/tests/bunit.testassets/SampleComponents/ComponentWithRelativeUnitAsWidth.razor b/tests/bunit.testassets/SampleComponents/ComponentWithRelativeUnitAsWidth.razor new file mode 100644 index 000000000..69e5a86c7 --- /dev/null +++ b/tests/bunit.testassets/SampleComponents/ComponentWithRelativeUnitAsWidth.razor @@ -0,0 +1,2 @@ +
+
\ No newline at end of file diff --git a/tests/bunit.tests/Rendering/RenderedComponentTest.cs b/tests/bunit.tests/Rendering/RenderedComponentTest.cs index df463be29..798b517ea 100644 --- a/tests/bunit.tests/Rendering/RenderedComponentTest.cs +++ b/tests/bunit.tests/Rendering/RenderedComponentTest.cs @@ -1,3 +1,4 @@ +using AngleSharp.Dom; using Bunit.Rendering; namespace Bunit; @@ -219,4 +220,44 @@ public void Test022() Should.Throw(() => target.Markup); } + + [Fact(DisplayName = "Searching first for derived component and then base component finds correct (#1691)")] + public void Test023() + { + var cut = Render( + ps => ps.AddChildContent() + .AddChildContent()); + + Should.NotThrow(() => + { + cut.FindComponents(); + cut.FindComponents(); + }); + } + + [Fact(DisplayName = "Using relative units in style attribute can be retrieved")] + public void Test024() + { + var cut = Render(); + + var text = cut.Find(".my-component").GetInnerText(); + + text.ShouldNotBeNull(); + } + + private class BaseComponent : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, "base"); + } + } + + private sealed class DerivedComponent : BaseComponent + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, "derived"); + } + } }