5272066bef
drawing_add_rough (знак шероховатости: ISymbols2DContainer.Roughs + IRoughParams, SignType ksRoughSignEnum, значение Ra/Rz через RoughParamText.Str), drawing_add_text (свободная надпись: IDrawingContainer.DrawingTexts + IText.Str), drawing_set_technical_requirements (блок тех. требований уровня документа: IDrawingDocument.TechnicalDemand.Text). - DrawingService: AddRoughAsync/AddTextAsync/SetTechnicalRequirementsAsync + ReadTechnicalRequirementsAsync + счётчики; RequireDrawingContainer/RequireTechnicalDemand - RoughSignType (enum + Parse/ToKompas), DrawingAnnotationResult (Value read-back из COM) - RequireNonEmptyText в DrawingValidation - 13 unit + 13 интеграционных тестов (всего 267 зелёных), сборка Release чистая Спайк подтвердил: значение шероховатости через IRoughParams.RoughParamText.Str (round-trip); текст НЕ в IView.ObjectCount (счёт по DrawingTexts.Count); тех. требования IsCreated False→True при первом Text.Str+Update, многострочно через \n. Ревью Codex спека учтено (height убран — это высота блока, не шрифт; guards; read-back возврат). Спек — docs/superpowers/specs/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
108 lines
4.0 KiB
C#
108 lines
4.0 KiB
C#
using Kompas.Mcp.Core.Documents;
|
|
using Kompas.Mcp.Core.Drawings;
|
|
using Kompas.Mcp.Core.Modeling;
|
|
|
|
namespace Kompas.Mcp.Tests.Integration;
|
|
|
|
/// <summary>Интеграция: знак шероховатости на виде (API7 ISymbols2DContainer.Roughs + IRoughParams).</summary>
|
|
[Trait("Category", "Integration")]
|
|
[Collection(KompasCollection.Name)]
|
|
public sealed class DrawingRoughTests : IntegrationTestBase
|
|
{
|
|
private readonly DocumentService _docs;
|
|
private readonly PartModeler _modeler;
|
|
private readonly DrawingService _drawing;
|
|
|
|
public DrawingRoughTests(KompasFixture fx) : base(fx)
|
|
{
|
|
_docs = new DocumentService(fx.Session, fx.Dispatcher);
|
|
_modeler = new PartModeler(fx.Session, fx.Dispatcher);
|
|
_drawing = new DrawingService(fx.Session, fx.Dispatcher);
|
|
}
|
|
|
|
private async Task<string> BuildAndSaveBoxAsync()
|
|
{
|
|
var path = TestPaths.NewFile(".m3d");
|
|
await _docs.CreateAsync(KompasDocumentType.Part);
|
|
try
|
|
{
|
|
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);
|
|
await _modeler.RebuildAsync();
|
|
await _docs.SaveAsAsync(path);
|
|
}
|
|
finally { await _docs.CloseAsync(save: false); }
|
|
return path;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Rough_is_placed_with_value_and_targets_view()
|
|
{
|
|
var partFile = await BuildAndSaveBoxAsync();
|
|
await _docs.CreateAsync(KompasDocumentType.Drawing);
|
|
try
|
|
{
|
|
var views = await _drawing.CreateStandardViewsAsync(partFile, 1.0, 100, 150);
|
|
var target = views.ViewNumbers[0];
|
|
|
|
var before = await _drawing.GetViewRoughCountAsync(target);
|
|
var r = await _drawing.AddRoughAsync(target, x: 20, y: 25, value: "Ra 1.6",
|
|
signType: RoughSignType.DeleteMaterial, angleDeg: 0);
|
|
var after = await _drawing.GetViewRoughCountAsync(target);
|
|
|
|
Assert.Equal(target, r.ViewNumber);
|
|
Assert.Equal("Ra 1.6", r.Value); // read-back из COM
|
|
Assert.Equal(before + 1, after);
|
|
}
|
|
finally { await _docs.CloseAsync(save: false); }
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Rough_without_value_is_placed()
|
|
{
|
|
var partFile = await BuildAndSaveBoxAsync();
|
|
await _docs.CreateAsync(KompasDocumentType.Drawing);
|
|
try
|
|
{
|
|
await _drawing.CreateStandardViewsAsync(partFile, 1.0, 100, 150);
|
|
var before = await _drawing.GetViewRoughCountAsync(0);
|
|
var r = await _drawing.AddRoughAsync(0, x: 15, y: 15, value: "",
|
|
signType: RoughSignType.NoProcessing, angleDeg: 0);
|
|
var after = await _drawing.GetViewRoughCountAsync(0);
|
|
Assert.Equal(before + 1, after);
|
|
Assert.Equal(string.Empty, r.Value);
|
|
}
|
|
finally { await _docs.CloseAsync(save: false); }
|
|
}
|
|
|
|
[Fact]
|
|
public async Task No_views_throws()
|
|
{
|
|
await _docs.CreateAsync(KompasDocumentType.Drawing);
|
|
try
|
|
{
|
|
await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
|
_drawing.AddRoughAsync(0, x: 0, y: 0, value: "Ra 1.6",
|
|
signType: RoughSignType.DeleteMaterial, angleDeg: 0));
|
|
}
|
|
finally { await _docs.CloseAsync(save: false); }
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Unknown_view_number_throws()
|
|
{
|
|
var partFile = await BuildAndSaveBoxAsync();
|
|
await _docs.CreateAsync(KompasDocumentType.Drawing);
|
|
try
|
|
{
|
|
await _drawing.CreateStandardViewsAsync(partFile, 1.0, 100, 150);
|
|
await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
|
_drawing.AddRoughAsync(999, x: 0, y: 0, value: "Ra 1.6",
|
|
signType: RoughSignType.DeleteMaterial, angleDeg: 0));
|
|
}
|
|
finally { await _docs.CloseAsync(save: false); }
|
|
}
|
|
}
|