-
-
Notifications
You must be signed in to change notification settings - Fork 117
Description
Describe the bug
After updating my nuget packages, my tests no longer pass. I suspect that this has something to do with my tests project now having a newer AngleSharp version. The issue seems to happen at least with both 1.0.5 and 1.0.4. I did not change any of the related test code (or the functionality the test tests) before the test started failing.
Example:
I can provide a component example but it kind of seems based on the exception that it is enough to have any anchor elements in the generated render fragment.
Both of these lines cause the exception to be thrown (after the first line which is just setup):
var cut = RenderComponent<Login>();
Assert.False(cut.Find("form button").HasAttribute("disabled"));
Assert.Contains(cut.Find("form button").Attributes, i => i.Name == "disabled");Results in this exception:
System.TypeLoadException: Method 'get_GivenNamespaceUri' in type 'AngleSharpWrappers.HtmlAnchorElementWrapper' from assembly 'AngleSharpWrappers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fe9c6306bcc1ce6f' does not have an implementation.
at Bunit.ElementWrapperFactory.Create(IElement element, IRenderedFragment renderedFragment, String cssSelector)
at Bunit.RenderedFragmentExtensions.Find(IRenderedFragment renderedFragment, String cssSelector) in /_/src/bunit.web/Extensions/RenderedFragmentExtensions.cs:line 28
at ThriveDevCenter.Client.Tests.Pages.Tests.LoginTests.LoginLocal_LoginButtonEnablesWhenTextInput() in /home/hhyyrylainen/Projects/ThriveDevCenter/Client.Tests/Pages.Tests/LoginTests.cs:line 84
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
But for example a simpler check like this passes:
cut.FindIsNull("form button");This is my full test that fails:
[Fact]
public void LoginLocal_LoginButtonEnablesWhenTextInput()
{
var mockCSRF = CSRFMockFactory.Create();
var http = Services.AddMockHttpClient();
http.When("/api/v1/Registration").RespondJson(false);
http.When("/LoginController").RespondJson(new LoginOptions
{
Categories = new List<LoginCategory>
{
new()
{
Name = "Local Account",
Options = new List<LoginOption>
{
new()
{
ReadableName = "Login using a local account",
InternalName = "local",
Active = true,
Local = true,
},
},
},
},
});
Services.AddSingleton(mockCSRF);
var cut = RenderComponent<Login>();
cut.WaitForAssertion(() => cut.FindIsNull(".spinner-border"));
Assert.Contains(cut.Find("form button").Attributes, i => i.Name == "disabled");
cut.Find("input[type=email]").Input("[email protected]");
cut.Find("input[type=password]").Input("12345");
Assert.DoesNotContain(cut.Find("form button").Attributes, i => i.Name == "disabled");
}Expected behavior:
I expected the Find method call to keep working. It seems that Find itself is not the problem but the required element wrapping that happens behind the scenes and tries to use a method in AngleSharp that no longer exists, or something like that?
Version info:
- bUnit version: 1.24.10
- .NET Runtime and Blazor version: Dotnet SDK 7.0.112 with Blazor WASM version: 7.0.13
- OS type and version: Fedora 38