Code review follow-up on acfe29e:
- Switch namespace to Strata.SqlTools.SqlBreakdown.Tests.PostgreSql to
match the dominant convention in the sibling test folder.
- Remove the unreachable SqlServer.CommandVisitor fallback in the
reflection helper. The Assert.That guard alone is enough to surface
a future regression.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using Strata.SqlTools.Visitors.PostgreSql;
|
|
|
|
namespace Strata.SqlTools.SqlBreakdown.Tests.PostgreSql;
|
|
|
|
[TestFixture]
|
|
public class CommandVisitorTests
|
|
{
|
|
[Test]
|
|
public void TwoVisitors_HaveIndependentParameterIndices()
|
|
{
|
|
var visitor1 = new CommandVisitor();
|
|
var visitor2 = new CommandVisitor();
|
|
|
|
var param1a = InvokeFormatParameterName(visitor1, "p");
|
|
var param1b = InvokeFormatParameterName(visitor1, "p");
|
|
var param2a = InvokeFormatParameterName(visitor2, "p");
|
|
|
|
Assert.That(param1a, Is.EqualTo("$1"), "first visitor's first parameter should be $1");
|
|
Assert.That(param1b, Is.EqualTo("$2"), "first visitor's second parameter should be $2");
|
|
Assert.That(param2a, Is.EqualTo("$1"), "second visitor must start at $1, not inherit visitor1's counter");
|
|
}
|
|
|
|
private static string InvokeFormatParameterName(CommandVisitor visitor, string name)
|
|
{
|
|
var method = typeof(CommandVisitor).GetMethod(
|
|
"FormatParameterName",
|
|
System.Reflection.BindingFlags.Instance
|
|
| System.Reflection.BindingFlags.NonPublic
|
|
| System.Reflection.BindingFlags.Public);
|
|
Assert.That(method, Is.Not.Null, "FormatParameterName must exist as a protected override on CommandVisitor");
|
|
return (string)method!.Invoke(visitor, new object[] { name })!;
|
|
}
|
|
}
|