|
2 | 2 | using Microsoft.CodeAnalysis.CSharp.Syntax; |
3 | 3 | using XafLogicExplainer.Core.Analyzers; |
4 | 4 | using XafLogicExplainer.Core.Catalog; |
| 5 | +using XafLogicExplainer.Core.Generators; |
5 | 6 | using XafLogicExplainer.Core.Models; |
| 7 | +using XafLogicExplainer.Mcp; |
| 8 | +using XafLogicExplainer.Mcp.Tools; |
6 | 9 |
|
7 | 10 | namespace XafLogicExplainer.Tests; |
8 | 11 |
|
@@ -246,6 +249,44 @@ public void DoesNotRegisterADbSetWrittenAsALocal() |
246 | 249 | Assert.DoesNotContain("AuditEntry", names); |
247 | 250 | } |
248 | 251 |
|
| 252 | + [Fact] |
| 253 | + public void DoesNotNameAnOrmTheSourceNeverNamed() |
| 254 | + { |
| 255 | + // Three renderers each decided this separately, in a binary with no third answer, so a |
| 256 | + // project whose ORM could not be determined was reported as XPO by two of them. The defect |
| 257 | + // was not the wrong answer -- it was that three places were each entitled to one. |
| 258 | + Assert.Equal("Not determined", Orm.Label("Unknown")); |
| 259 | + Assert.Equal("an undetermined ORM", Orm.DisplayName("Unknown")); |
| 260 | + |
| 261 | + // A null has not learned XPO either. Anything that never ran detection is unknown. |
| 262 | + Assert.True(Orm.IsUnknown(null)); |
| 263 | + Assert.False(Orm.IsEfCore("Unknown")); |
| 264 | + } |
| 265 | + |
| 266 | + [Fact] |
| 267 | + public void TheHtmlExplainerDoesNotClaimXpoForAnUndeterminedProject() |
| 268 | + { |
| 269 | + var page = new HtmlExplainerGenerator("0.0.0").Generate(SampleProjects.NoOrm); |
| 270 | + |
| 271 | + Assert.DoesNotContain("<strong>XPO</strong>", page); |
| 272 | + Assert.Contains("Not determined", page); |
| 273 | + } |
| 274 | + |
| 275 | + [Fact] |
| 276 | + public async Task TheMcpOverviewDoesNotClaimXpoForAnUndeterminedProject() |
| 277 | + { |
| 278 | + // The surface that speaks with the most authority: `xaf_overview` prints the ORM two lines |
| 279 | + // above "These lists are complete, not sampled", from a tool whose description tells the |
| 280 | + // agent that anything absent does not exist in the application. |
| 281 | + var tools = new XafDiscoveryTools(new XafProjectContext( |
| 282 | + [new XafProjectSource { Name = "SampleNoOrm", Path = SampleProjects.NoOrmPath, Language = "en" }])); |
| 283 | + |
| 284 | + var overview = await tools.OverviewAsync(cancellationToken: TestContext.Current.CancellationToken); |
| 285 | + |
| 286 | + Assert.DoesNotContain("**XPO**", overview); |
| 287 | + Assert.Contains("Not determined", overview); |
| 288 | + } |
| 289 | + |
249 | 290 | private static ControllerTargeting Read(string source) => |
250 | 291 | ControllerTargetingReader.Read(CSharpSyntaxTree.ParseText(source).GetRoot() |
251 | 292 | .DescendantNodes().OfType<ClassDeclarationSyntax>().First()); |
|
0 commit comments