fc99739e1e
RibAsync (o3d_ribOperation): SetSketch + index/angle/side + SetThinParam. SketchGeometry.RibSide маппинг (left/right/up/down). Инструмент rib в FeatureTools. Эмпирически: контур ребра висит в зазоре (не касается тела), side=left для косынки. Integration: L-уголок + ребро в углу → объём растёт. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
68 lines
2.5 KiB
C#
68 lines
2.5 KiB
C#
using Kompas.Mcp.Core.Modeling;
|
|
|
|
namespace Kompas.Mcp.Tests;
|
|
|
|
[Trait("Category", "Unit")]
|
|
public sealed class SketchGeometryTests
|
|
{
|
|
[Theory]
|
|
[InlineData(true, 1)]
|
|
[InlineData(false, -1)]
|
|
public void ArcDirection_maps_orientation(bool ccw, int expected)
|
|
=> Assert.Equal(expected, (int)SketchGeometry.ArcDirection(ccw));
|
|
|
|
[Theory]
|
|
[InlineData(true, false)] // вписанный → describe=false
|
|
[InlineData(false, true)] // описанный → describe=true
|
|
public void PolygonDescribe_inverts_inscribed(bool inscribed, bool expected)
|
|
=> Assert.Equal(expected, SketchGeometry.PolygonDescribe(inscribed));
|
|
|
|
[Theory]
|
|
[InlineData("left", 0)]
|
|
[InlineData("right", 1)]
|
|
[InlineData("up", 2)]
|
|
[InlineData("down", 3)]
|
|
[InlineData("UP", 2)]
|
|
public void RibSide_maps_known(string side, int expected)
|
|
=> Assert.Equal(expected, (int)SketchGeometry.RibSide(side));
|
|
|
|
[Fact]
|
|
public void RibSide_throws_on_unknown()
|
|
=> Assert.Throws<ArgumentException>(() => SketchGeometry.RibSide("diagonal"));
|
|
|
|
[Fact]
|
|
public void RequirePositive_throws_on_zero_or_negative()
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => SketchGeometry.RequirePositive(0, "radius"));
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => SketchGeometry.RequirePositive(-1, "radius"));
|
|
Assert.Null(Record.Exception(() => SketchGeometry.RequirePositive(0.1, "radius")));
|
|
}
|
|
|
|
[Fact]
|
|
public void RequireVertexCount_throws_below_three()
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => SketchGeometry.RequireVertexCount(2));
|
|
Assert.Null(Record.Exception(() => SketchGeometry.RequireVertexCount(3)));
|
|
}
|
|
|
|
[Fact]
|
|
public void RequirePoints_throws_on_null()
|
|
=> Assert.Throws<ArgumentNullException>(
|
|
() => SketchGeometry.RequirePoints(null!, 2, "points"));
|
|
|
|
[Fact]
|
|
public void RequirePoints_throws_when_too_few()
|
|
=> Assert.Throws<ArgumentException>(
|
|
() => SketchGeometry.RequirePoints(new[] { (0.0, 0.0) }, 2, "points"));
|
|
|
|
[Fact]
|
|
public void RequirePoints_throws_on_non_finite()
|
|
=> Assert.Throws<ArgumentException>(
|
|
() => SketchGeometry.RequirePoints(new[] { (0.0, 0.0), (double.NaN, 1.0) }, 2, "points"));
|
|
|
|
[Fact]
|
|
public void RequirePoints_passes_on_valid()
|
|
=> Assert.Null(Record.Exception(
|
|
() => SketchGeometry.RequirePoints(new[] { (0.0, 0.0), (1.0, 1.0) }, 2, "points")));
|
|
}
|