From b432560789e56cf58fb0b8f5df7833f823cd3a57 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Mon, 2 Feb 2026 22:33:34 +0000 Subject: [PATCH] Make hover test assertions more specific Assert on actual hover content (type names and symbol names) instead of just checking for non-empty content. This verifies hover returns meaningful type information from Roslyn. --- test/solidlsp/csharp/test_csharp_basic.py | 39 ++++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/test/solidlsp/csharp/test_csharp_basic.py b/test/solidlsp/csharp/test_csharp_basic.py index ef478dbf..1638f73d 100644 --- a/test/solidlsp/csharp/test_csharp_basic.py +++ b/test/solidlsp/csharp/test_csharp_basic.py @@ -132,46 +132,47 @@ class TestCSharpLanguageServer: @pytest.mark.parametrize("language_server", [Language.CSHARP], indirect=True) def test_hover_includes_type_information(self, language_server: SolidLanguageServer) -> None: - """Test that hover information is available and includes original symbol names with type annotations.""" + """Test that hover information is available and includes type information.""" file_path = os.path.join("Models", "Person.cs") # Open the file first language_server.open_file(file_path) - # Test 1: Hover over the Name property name (line 6, column 23 - on "Name") - # public string Name { get; set; } + # Test 1: Hover over the Name property (line 6, column 23 - on "Name") + # Source: public string Name { get; set; } hover_info = language_server.request_hover(file_path, 6, 23) - # Verify hover has content + # Verify hover returns content assert hover_info is not None, "Hover should return information for Name property" assert isinstance(hover_info, dict), "Hover should be a dict" assert "contents" in hover_info, "Hover should have contents" contents = hover_info["contents"] - if isinstance(contents, dict) and "value" in contents: - hover_text = contents["value"] - assert hover_text is not None and len(hover_text) > 0, "Hover should have content" + assert isinstance(contents, dict), "Hover contents should be a dict" + assert "value" in contents, "Hover contents should have value" + hover_text = contents["value"] - # Check if the injected type annotation appears in hover - # Original name should be "Name : string" which we inject at the top - # Note: This might not always appear if Roslyn's hover already includes it - # So we just verify there's meaningful content - assert len(hover_text) > 10, "Hover should have substantial content" + # Verify the hover contains property signature with type + assert "string" in hover_text, f"Hover should include 'string' type, got: {hover_text}" + assert "Name" in hover_text, f"Hover should include 'Name' property name, got: {hover_text}" - # Test 2: Hover over the IsAdult method name (line 22, column 21 - on "IsAdult") - # public bool IsAdult() + # Test 2: Hover over the IsAdult method (line 22, column 21 - on "IsAdult") + # Source: public bool IsAdult() hover_method = language_server.request_hover(file_path, 22, 21) - # Verify method hover has content + # Verify method hover returns content assert hover_method is not None, "Hover should return information for IsAdult method" assert isinstance(hover_method, dict), "Hover should be a dict" assert "contents" in hover_method, "Hover should have contents" contents = hover_method["contents"] - if isinstance(contents, dict) and "value" in contents: - method_hover_text = contents["value"] - # Original name should be "IsAdult() : bool" injected at the top - assert method_hover_text is not None and len(method_hover_text) > 10, "Method hover should have substantial content" + assert isinstance(contents, dict), "Hover contents should be a dict" + assert "value" in contents, "Hover contents should have value" + method_hover_text = contents["value"] + + # Verify the hover contains method signature with return type + assert "bool" in method_hover_text, f"Hover should include 'bool' return type, got: {method_hover_text}" + assert "IsAdult" in method_hover_text, f"Hover should include 'IsAdult' method name, got: {method_hover_text}" @pytest.mark.csharp