Every test asserts something - #70
Merged
Merged
Conversation
…nothing throws (#69) Fifteen tests reported NoError rather than Success - they passed without asserting. Most were making a real claim invisibly, so each now says it: - The MimicTest set: a Mimic's members, calls, indexes and operators all yield another Mimic, and a conversion yields the target type's default-constructed value. Asserting that would have caught a Mimic that started returning null, which "does not throw" would not. - The two void tests: VoidMethodPoco records that it ran, so the test asserts the call reached the target rather than merely that the dynamic invocation survived. - The two mock operator tests: Moq verifies TryBinaryOperation was actually reached, which is the thing being tested. - GenericStructInNullableContextTest: the proxy builds *and* works. - Set_Index, where there is no value to inspect, is an explicit Assert.DoesNotThrow. PrintOutInterface was not a test at all - it printed a generated ILinq<T> to the console and could not fail. The members it generates are how that interface was authored, so it now asserts the generation still produces them; an empty or shapeless run means the reflection stopped matching. 190 on net8.0 and net10.0, 196 on net47, 101 on wasm, and the NoError count is 0. Closes #69. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016mwfq4oeZW8SiD4HjTHYdg
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved findings remain in generated-member matching and Mimic operator coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
This PR adds explicit assertions to previously assertion-free tests, improving test-result reliability.
Changes:
- Verifies Mimic operations, conversions, proxy behavior, and void dispatch.
- Validates dynamic binary-operation dispatch and generated LINQ members.
- Adds tracking support for confirming void calls execute.
| File | Reviewed changes |
|---|---|
Tests/UnitTestImpromptuInterface/Support/SupportDefinitions.cs |
Adds void-call tracking support. |
Tests/UnitTestImpromptuInterface/SingleMethodInvoke.cs |
Verifies binary-operation dispatch. |
Tests/UnitTestImpromptuInterface/MimicTest.cs |
Adds Mimic behavior and conversion assertions. |
Tests/UnitTestImpromptuInterface/Linq.cs |
Checks generated LINQ members. |
Tests/UnitTestImpromptuInterface/ImpromptuDynamic.cs |
Confirms void calls reach their targets. |
Tests/UnitTestImpromptuInterface/Basic.cs |
Verifies generic-struct proxy behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+144
to
+153
| var generated = tList | ||
| .Where(it => it.GetParameters().Any() | ||
| && (HelperIsGenericExtension(it, typeof(IEnumerable<>)) | ||
| || it.GetParameters().First().ParameterType == typeof(IEnumerable))) | ||
| .Select(HelperMakeName) | ||
| .ToList(); | ||
|
|
||
| Assert.IsNotEmpty(generated); | ||
| foreach (var expected in new[] { "Where", "Select", "First" }) | ||
| Assert.IsTrue(generated.Any(it => it.Contains(expected)), "generated ILinq<T> declares " + expected); |
| result = mimic |= true; | ||
| result = mimic &= false; | ||
| result = mimic %= 5; | ||
| Assert.IsInstanceOf<Mimic>(result); // an operator on a Mimic is a Mimic |
This was referenced Sep 24, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #69.
Fifteen tests reported
NoErrorrather thanSuccess— they passed without asserting anything. The count is now 0, and no test was deleted to get there.Most of them were making a real claim invisibly, so each now states it:
MimicTest×9dynamic result = mimic.A.B.C;Mimic; a conversion yields the target type's default valueGetterVoidTest,ForwardVoidTesttTest.Action();VoidMethodPocorecords that it ran, so the call is proven to have reached the targetTestInvokeAddDynamic,TestInvokeSubtractDynamicTryBinaryOperationwas reached — the thing being testedGenericStructInNullableContextTestSet_IndexAssert.DoesNotThrowThe
Mimicones are the clearest gain: the old versions would not have noticed aMimicthat started returningnullinstead of anotherMimic, because not throwing was the whole test.PrintOutInterfacewas not a test. It printed a generatedILinq<T>declaration to the console and could not fail. Rather than delete it, it now asserts that the generation still produces the membersILinq<T>was authored from — an empty or shapeless run means the reflection stopped matching, which is worth knowing when a new .NET version reshapesEnumerable.One fixture change, additive:
VoidMethodPocogains aRanproperty.Verified: 190 on net8.0 and net10.0, 196 on net47, 101 on browser-wasm,
NoErrorcount 0.🤖 Generated with Claude Code
https://claude.ai/code/session_016mwfq4oeZW8SiD4HjTHYdg