using Kompas.Mcp.Core.Documents; using Kompas.Mcp.Core.Modeling; using Kompas.Mcp.Core.Query; namespace Kompas.Mcp.Tests.Integration; /// Интеграция: формообразующие операции пакета B. [Trait("Category", "Integration")] [Collection(KompasCollection.Name)] public sealed class FeatureOpsTests { private readonly DocumentService _docs; private readonly PartModeler _modeler; private readonly QueryService _query; public FeatureOpsTests(KompasFixture fx) { _docs = new DocumentService(fx.Session, fx.Dispatcher); _modeler = new PartModeler(fx.Session, fx.Dispatcher); _query = new QueryService(fx.Session, fx.Dispatcher); } [Fact] public async Task Shell_box_hollows_with_open_cap() { await _docs.CreateAsync(KompasDocumentType.Part); try { // Коробка 40×30×20. var s = await _modeler.OpenSketchAsync(BasePlane.XOY); await _modeler.AddRectangleAsync(s, 0, 0, 40, 30); await _modeler.CloseSketchAsync(s); await _modeler.ExtrudeAsync(s, depth: 20); var before = (await _query.GetPartInfoAsync()).Volume; // 24000 // Удаляем один из двух плоских торцов (площадь 40×30=1200) → открытая оболочка. // Какой именно торец (верх/низ) — для объёма не важно: результат симметричен. var faces = await _query.ListFacesAsync(); var cap = faces.First(f => f.Type == "plane" && Math.Abs(f.Area - 1200) < 1); var id = await _modeler.ShellAsync(new[] { cap.Index }, thickness: 2, outward: false); Assert.True(id > 0); await _modeler.RebuildAsync(); // Оболочка 2 мм с открытым торцом: 24000 − 36×26×18 = 7152 мм³. var after = (await _query.GetPartInfoAsync()).Volume; Assert.True(after < before, "После оболочки объём должен уменьшиться."); Assert.InRange(after, 7152 * 0.95, 7152 * 1.05); } finally { await _docs.CloseAsync(save: false); } } }