From 76eb4ac4ec00a0d1b113c3134943f38f9ae8b567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 25 Jun 2026 10:15:04 +0200 Subject: [PATCH 1/2] Add eval coverage for dotnet-test/writing-mstest-tests Enrich the ServiceRegistry collection/null/reference scenario with deterministic file_contains assertions for the modern MSTest assertion APIs Assert.IsNull, Assert.AreSame, Assert.Contains, Assert.DoesNotContain, Assert.IsEmpty, and Assert.IsNotEmpty. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../writing-mstest-tests/eval.yaml | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/dotnet-test/writing-mstest-tests/eval.yaml b/tests/dotnet-test/writing-mstest-tests/eval.yaml index dd7c6120fa..ea1b0a78b7 100644 --- a/tests/dotnet-test/writing-mstest-tests/eval.yaml +++ b/tests/dotnet-test/writing-mstest-tests/eval.yaml @@ -407,7 +407,7 @@ scenarios: # ============================================================================ - name: "Write tests with collection, null, and reference assertions" - prompt: "Write MSTest tests for my ServiceRegistry class using the most appropriate assertion for each check. I need tests that verify registration, resolution returning the same instance, null for unregistered services, clearing all services, and removal." + prompt: "Write MSTest tests for my ServiceRegistry class using the most appropriate assertion for each check. I need tests that verify: registering a service and resolving it returns the exact same instance; resolving an unregistered service returns null; the GetAll list contains a registered service and does not contain it after removal; and GetAll is empty before any registration but not empty afterwards." setup: files: - path: "src/ServiceRegistry.cs" @@ -462,11 +462,29 @@ scenarios: - type: file_contains path: "tests/*.cs" value: "[TestClass]" + - type: file_contains + path: "tests/*.cs" + value: "Assert.AreSame" + - type: file_contains + path: "tests/*.cs" + value: "Assert.IsNull" + - type: file_contains + path: "tests/*.cs" + value: "Assert.Contains" + - type: file_contains + path: "tests/*.cs" + value: "Assert.DoesNotContain" + - type: file_contains + path: "tests/*.cs" + value: "Assert.IsEmpty" + - type: file_contains + path: "tests/*.cs" + value: "Assert.IsNotEmpty" rubric: - - "Verifies reference identity (same object instance, not just value equality) when testing that resolving a registered service returns the exact object that was registered" - - "Checks that resolving an unregistered service type returns null, using a null-specific assertion rather than a boolean check" - - "Asserts the collection is empty after calling Clear, using a dedicated empty-collection assertion rather than checking count manually" - - "Verifies that a removed service is no longer resolvable after calling Remove (e.g., returns null or is absent from the collection)" + - "Verifies reference identity (same object instance, not just value equality) using Assert.AreSame when testing that resolving a registered service returns the exact object that was registered" + - "Checks that resolving an unregistered service type returns null, using Assert.IsNull rather than a boolean check" + - "Uses Assert.Contains to verify the GetAll collection includes a registered service, and Assert.DoesNotContain to verify it is absent after Remove" + - "Asserts the collection is empty with Assert.IsEmpty before registration and not empty with Assert.IsNotEmpty afterwards, rather than checking count manually" - "The written tests reference correct class and method names from the provided source code" timeout: 180 From 81c1b2094c13d81619588b3ca975876826755f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 25 Jun 2026 10:32:38 +0200 Subject: [PATCH 2/2] Reject legacy CollectionAssert/StringAssert helpers in collection scenario Address PR review: file_contains is a case-sensitive substring check, so the Assert.Contains and Assert.DoesNotContain value checks would also pass for CollectionAssert.* and StringAssert.* helpers. Add file_not_contains guards to keep the scenario a deterministic check for the modern Assert.* API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/dotnet-test/writing-mstest-tests/eval.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/dotnet-test/writing-mstest-tests/eval.yaml b/tests/dotnet-test/writing-mstest-tests/eval.yaml index ea1b0a78b7..35bb69ce41 100644 --- a/tests/dotnet-test/writing-mstest-tests/eval.yaml +++ b/tests/dotnet-test/writing-mstest-tests/eval.yaml @@ -480,6 +480,22 @@ scenarios: - type: file_contains path: "tests/*.cs" value: "Assert.IsNotEmpty" + # Guard the substring-based file_contains checks above against the legacy + # CollectionAssert/StringAssert helpers (e.g. "CollectionAssert.Contains" + # also contains the substring "Assert.Contains"). Rejecting them keeps the + # scenario a deterministic check for the modern Assert.* API. + - type: file_not_contains + path: "tests/*.cs" + value: "CollectionAssert.Contains" + - type: file_not_contains + path: "tests/*.cs" + value: "CollectionAssert.DoesNotContain" + - type: file_not_contains + path: "tests/*.cs" + value: "StringAssert.Contains" + - type: file_not_contains + path: "tests/*.cs" + value: "StringAssert.DoesNotContain" rubric: - "Verifies reference identity (same object instance, not just value equality) using Assert.AreSame when testing that resolving a registered service returns the exact object that was registered" - "Checks that resolving an unregistered service type returns null, using Assert.IsNull rather than a boolean check"