8afad88241
Базовый класс IntegrationTestBase (IAsyncLifetime) закрывает все открытые документы КОМПАС после КАЖДОГО теста (DocumentService.CloseAllAsync) — чтобы не копились вкладки-пустышки и упавший Assert не оставлял открытый документ. Все интеграционные тест-классы переведены на него (: base(fx)); индивидуальные finally CloseAsync сохранены как первичная очистка. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using Kompas.Mcp.Core.Documents;
|
|
using Kompas.Mcp.Core.Modeling;
|
|
using Kompas.Mcp.Core.Validation;
|
|
|
|
namespace Kompas.Mcp.Tests.Integration;
|
|
|
|
/// <summary>Интеграция: валидация построения (ошибки/перестроение операций).</summary>
|
|
[Trait("Category", "Integration")]
|
|
[Collection(KompasCollection.Name)]
|
|
public sealed class ValidationTests : IntegrationTestBase
|
|
{
|
|
private readonly DocumentService _docs;
|
|
private readonly PartModeler _modeler;
|
|
private readonly ValidationService _validation;
|
|
|
|
public ValidationTests(KompasFixture fx) : base(fx)
|
|
{
|
|
_docs = new DocumentService(fx.Session, fx.Dispatcher);
|
|
_modeler = new PartModeler(fx.Session, fx.Dispatcher);
|
|
_validation = new ValidationService(fx.Session, fx.Dispatcher);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Valid_part_reports_no_errors()
|
|
{
|
|
await _docs.CreateAsync(KompasDocumentType.Part);
|
|
try
|
|
{
|
|
var s = await _modeler.OpenSketchAsync(BasePlane.XOY);
|
|
await _modeler.AddRectangleAsync(s, 0, 0, 20, 20);
|
|
await _modeler.CloseSketchAsync(s);
|
|
await _modeler.ExtrudeAsync(s, depth: 10);
|
|
await _modeler.RebuildAsync();
|
|
|
|
var errors = await _validation.ValidatePartAsync();
|
|
|
|
Assert.Empty(errors);
|
|
}
|
|
finally
|
|
{
|
|
await _docs.CloseAsync(save: false);
|
|
}
|
|
}
|
|
}
|