Files
kompas3d-mcp/tests/Kompas.Mcp.Tests/Integration/FaceEditTests.cs
T
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

52 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Kompas.Mcp.Core.Documents;
using Kompas.Mcp.Core.Editing;
using Kompas.Mcp.Core.Modeling;
using Kompas.Mcp.Core.Query;
namespace Kompas.Mcp.Tests.Integration;
/// <summary>Интеграция: прямое редактирование — перемещение грани (FaceMover).</summary>
[Trait("Category", "Integration")]
[Collection(KompasCollection.Name)]
public sealed class FaceEditTests : IntegrationTestBase
{
private readonly DocumentService _docs;
private readonly PartModeler _modeler;
private readonly FaceEditService _faceEdit;
private readonly QueryService _query;
public FaceEditTests(KompasFixture fx) : base(fx)
{
_docs = new DocumentService(fx.Session, fx.Dispatcher);
_modeler = new PartModeler(fx.Session, fx.Dispatcher);
_faceEdit = new FaceEditService(fx.Session, fx.Dispatcher);
_query = new QueryService(fx.Session, fx.Dispatcher);
}
[Fact]
public async Task Move_face_grows_part_height_by_offset()
{
await _docs.CreateAsync(KompasDocumentType.Part);
try
{
// Брусок 30×20×10 на XOY: X[0;30], Y[0;20], Z[0;10]. Верхняя грань — Z=10, центр (15,10,10).
var s = await _modeler.OpenSketchAsync(BasePlane.XOY);
await _modeler.AddRectangleAsync(s, 0, 0, 30, 20);
await _modeler.CloseSketchAsync(s);
await _modeler.ExtrudeAsync(s, depth: 10);
await _modeler.RebuildAsync();
// Толкаем верхнюю грань на +2 мм наружу → высота 10 → 12.
await _faceEdit.MoveFaceAsync(15, 10, 10, distance: 2);
await _modeler.RebuildAsync();
var bb = await _query.GetBoundingBoxAsync();
Assert.InRange(bb.SizeZ, 11.9, 12.1);
}
finally
{
await _docs.CloseAsync(save: false);
}
}
}