test: add workbench tests and MVP documentation

This commit is contained in:
codex
2026-07-30 13:19:04 +03:00
parent 86fb8c89d2
commit 3f2fbe9883
12 changed files with 116 additions and 0 deletions
@@ -0,0 +1,10 @@
namespace DocumentAutomation.IntegrationTests;
public sealed class WordComIntegrationTests
{
[Fact(Skip = "Requires an interactive Microsoft Word installation; not run automatically in the repository validation pass.")]
public void BuildsDocxAndExportsPdfThroughWordCom()
{
Assert.Fail("Run this test manually on a Windows workstation with Word installed and a synthetic template/body fixture.");
}
}
@@ -0,0 +1,20 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocxWorkbench.OpenXml;
namespace DocxWorkbench.Tests;
public sealed class DocumentInspectorTests
{
[Fact]
public void InspectsSyntheticDocxStructure()
{
var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".docx");
using (var doc = WordprocessingDocument.Create(path, DocumentFormat.OpenXml.WordprocessingDocumentType.Document))
{
var main = doc.AddMainDocumentPart(); main.Document = new Document(new Body(new Paragraph(new Run(new Text("{{DOC_BODY}}"))), new Table(new TableRow(new TableCell(new Paragraph(new Run(new Text("x")))))))); main.Document.Save();
}
try { var result = new DocumentInspector().Inspect(path); Assert.Equal(1, result.Tables); Assert.True(result.Paragraphs >= 2); Assert.True(result.HasPageFields is false); }
finally { File.Delete(path); }
}
}
@@ -0,0 +1,26 @@
using DocumentAutomation.Shared;
using StandardsWorkbench.Core;
namespace StandardsWorkbench.Tests;
public sealed class RulesEngineTests
{
[Fact]
public void OnlyApprovedRulesAreEvaluated()
{
var document = new DocumentInspectionResult { FilePath = "synthetic.docx", ContentControls = 1, Sections = 1, Paragraphs = 2, Tables = 0 };
var profile = new ApprovedRulesProfile { StandardId = "TEST", Code = "TEST", Revision = "1", Rules = [
new CandidateRule { CandidateId = "approved", StandardId = "TEST", ClauseId = "1", SourceText = "x", Title = "x", RuleKind = "ContentControlPresence", Status = "Approved" },
new CandidateRule { CandidateId = "new", StandardId = "TEST", ClauseId = "2", SourceText = "x", Title = "x", RuleKind = "SectionCount", Status = "New" }
], SourceFileSha256 = "test"};
var result = new RulesEngine().Evaluate(document, profile); Assert.Single(result); Assert.Equal(RuleEvaluationStatus.Pass, result[0].Status);
}
[Fact]
public void FailedRuleHasClauseReference()
{
var document = new DocumentInspectionResult { FilePath = "synthetic.docx", ContentControls = 0, Sections = 1, Paragraphs = 1, Tables = 0 };
var rule = new CandidateRule { CandidateId = "cc", StandardId = "TEST", ClauseId = "6.3", SourcePage = 4, SourceText = "required", Title = "cc", RuleKind = "ContentControlPresence", Status = "Tested" };
var result = Assert.Single(new RulesEngine().Evaluate(document, new ApprovedRulesProfile { StandardId = "TEST", Code = "TEST", Revision = "1", SourceFileSha256 = "test", Rules = [rule] })); Assert.Equal(RuleEvaluationStatus.Fail, result.Status); Assert.Equal("6.3", result.ClauseId); Assert.Equal(4, result.SourcePage);
}
}