de063290f4
Веха 2 (2D-ЧЕРТЁЖ), инкремент 1. Новый DrawingService (API7, namespace
Kompas.Mcp.Core.Drawings): doc2d.ViewsAndLayersManager.Views.AddStandartViews(
path, "#Спереди", {1,3,5}=front/top/left, x, y, scale, 20, 20). Новый DrawingTools
(инструмент drawing_create_standard_views), регистрация в DI.
Подтверждено спайком: object[]→SAFEARRAY VT_I4 ОК, 3 вида создаются (Count 1→4).
Ревью Codex спека учтено: File.Exists+Length>0; created==3 строго; гарантия
непустоты (сумма ObjectCount>0); опц. x,y (повторный вызов не стопкой); record
DrawingViewsResult{Created,Total}. Точечный release RCW отклонён (v2-2).
Валидация — чистый DrawingValidation (расширение .m3d/.a3d, scale>0).
Тесты: +16 unit (DrawingValidation), +3 integration (DrawingTests: создание 3 видов,
отклонение не-чертежа, несуществующий файл). Итого 114 unit + 61 integration = 175.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using Kompas.Mcp.Core.Drawings;
|
|
|
|
namespace Kompas.Mcp.Tests;
|
|
|
|
[Trait("Category", "Unit")]
|
|
public sealed class DrawingValidationTests
|
|
{
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
public void NormalizeModelPath_throws_on_empty(string? path)
|
|
=> Assert.Throws<ArgumentException>(() => DrawingValidation.NormalizeModelPath(path));
|
|
|
|
[Theory]
|
|
[InlineData(@"C:\m\part.step")]
|
|
[InlineData(@"C:\m\part.txt")]
|
|
[InlineData(@"C:\m\part")]
|
|
public void NormalizeModelPath_throws_on_wrong_extension(string path)
|
|
=> Assert.Throws<ArgumentException>(() => DrawingValidation.NormalizeModelPath(path));
|
|
|
|
[Theory]
|
|
[InlineData(@"C:\m\part.m3d", ".m3d")]
|
|
[InlineData(@"C:\m\frame.a3d", ".a3d")]
|
|
[InlineData(@" C:\m\part.M3D ", ".m3d")]
|
|
public void NormalizeModelPath_accepts_model_files(string path, string expectedExt)
|
|
{
|
|
var result = DrawingValidation.NormalizeModelPath(path);
|
|
Assert.True(Path.IsPathFullyQualified(result));
|
|
Assert.EndsWith(expectedExt, result, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(-1)]
|
|
[InlineData(double.NaN)]
|
|
[InlineData(double.PositiveInfinity)]
|
|
public void RequireScale_throws_on_non_positive_or_non_finite(double scale)
|
|
=> Assert.Throws<ArgumentOutOfRangeException>(() => DrawingValidation.RequireScale(scale));
|
|
|
|
[Theory]
|
|
[InlineData(1.0)]
|
|
[InlineData(0.5)]
|
|
[InlineData(2.0)]
|
|
public void RequireScale_accepts_positive(double scale)
|
|
=> Assert.Null(Record.Exception(() => DrawingValidation.RequireScale(scale)));
|
|
}
|