Files
mikhail 8afad88241 test: per-test очистка документов через IntegrationTestBase (CloseAllAsync)
Базовый класс IntegrationTestBase (IAsyncLifetime) закрывает все открытые
документы КОМПАС после КАЖДОГО теста (DocumentService.CloseAllAsync) — чтобы не
копились вкладки-пустышки и упавший Assert не оставлял открытый документ. Все
интеграционные тест-классы переведены на него (: base(fx)); индивидуальные
finally CloseAsync сохранены как первичная очистка.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 13:38:48 +03:00

43 lines
1.3 KiB
C#

using Kompas.Mcp.Core.Documents;
namespace Kompas.Mcp.Tests.Integration;
/// <summary>Интеграция: жизненный цикл документов.</summary>
[Trait("Category", "Integration")]
[Collection(KompasCollection.Name)]
public sealed class DocumentTests : IntegrationTestBase
{
private readonly DocumentService _docs;
public DocumentTests(KompasFixture fx) : base(fx)
=> _docs = new DocumentService(fx.Session, fx.Dispatcher);
[Fact]
public async Task Create_part_saveas_close_roundtrip()
{
var created = await _docs.CreateAsync(KompasDocumentType.Part);
Assert.Equal(KompasDocumentType.Part, created.Type);
var path = TestPaths.NewFile(".m3d");
await _docs.SaveAsAsync(path);
var active = await _docs.GetActiveAsync();
Assert.NotNull(active);
Assert.Equal(path, active!.PathName, ignoreCase: true);
var closed = await _docs.CloseAsync(save: false);
Assert.True(closed);
Assert.True(File.Exists(path));
}
[Fact]
public async Task Create_fragment_reports_type()
{
await _docs.CreateAsync(KompasDocumentType.Fragment);
var active = await _docs.GetActiveAsync();
Assert.NotNull(active);
Assert.Equal(KompasDocumentType.Fragment, active!.Type);
await _docs.CloseAsync(save: false);
}
}