Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="ConjugatedPortTypingExtensionsTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2026 Starion Group S.A.
//
//
// Copyright (C) 2022-2026 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// </copyright>
// ------------------------------------------------------------------------------------------------

Expand All @@ -26,6 +26,7 @@ namespace SysML2.NET.Tests.Extend

using SysML2.NET.Core.POCO.Root.Namespaces;
using SysML2.NET.Core.POCO.Systems.Ports;
using SysML2.NET.Exceptions;
using SysML2.NET.Extensions;

[TestFixture]
Expand All @@ -36,10 +37,15 @@ public void VerifyComputePortDefinition()
{
Assert.That(() => ((IConjugatedPortTyping)null).ComputePortDefinition(), Throws.TypeOf<ArgumentNullException>());

// No ConjugatedPortDefinition -> the null-safe navigation short-circuits to null.
// No ConjugatedPortDefinition -> [1..1] violation.
var emptyConjugatedPortTyping = new ConjugatedPortTyping();

Assert.That(emptyConjugatedPortTyping.ComputePortDefinition(), Is.Null);
Assert.That(emptyConjugatedPortTyping.ComputePortDefinition, Throws.TypeOf<IncompleteModelException>());

// A ConjugatedPortDefinition with no ownership chain resolves no originalPortDefinition.
var unownedConjugatedPortTyping = new ConjugatedPortTyping { ConjugatedPortDefinition = new ConjugatedPortDefinition() };

Assert.That(unownedConjugatedPortTyping.ComputePortDefinition, Throws.TypeOf<IncompleteModelException>());

// Positive case: the ConjugatedPortDefinition's originalPortDefinition derives from its
// owningMembership -> membershipOwningNamespace, which must be a PortDefinition. Wire that
Expand Down
17 changes: 9 additions & 8 deletions SysML2.NET.Tests/Extend/CrossSubsettingExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="CrossSubsettingExtensionsTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2026 Starion Group S.A.
//
//
// Copyright (C) 2022-2026 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// </copyright>
// ------------------------------------------------------------------------------------------------

Expand All @@ -27,6 +27,7 @@ namespace SysML2.NET.Tests.Extend
using SysML2.NET.Core.POCO.Core.Features;
using SysML2.NET.Core.POCO.Root.Elements;
using SysML2.NET.Core.POCO.Root.Namespaces;
using SysML2.NET.Exceptions;

[TestFixture]
public class CrossSubsettingExtensionsTestFixture
Expand All @@ -38,7 +39,7 @@ public void VerifyComputeCrossingFeature()

var crossSubsetting = new CrossSubsetting();

Assert.That(crossSubsetting.ComputeCrossingFeature(), Is.Null);
Assert.That(crossSubsetting.ComputeCrossingFeature, Throws.TypeOf<IncompleteModelException>());

var feature = new Feature();

Expand All @@ -51,7 +52,7 @@ public void VerifyComputeCrossingFeature()

((IContainedRelationship)nonFeatureCrossSubsetting).OwningRelatedElement = nonFeatureOwner;

Assert.That(nonFeatureCrossSubsetting.ComputeCrossingFeature(), Is.Null);
Assert.That(nonFeatureCrossSubsetting.ComputeCrossingFeature, Throws.TypeOf<IncompleteModelException>());
}
}
}
17 changes: 9 additions & 8 deletions SysML2.NET.Tests/Extend/DifferencingExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="DifferencingExtensionsTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2026 Starion Group S.A.
//
//
// Copyright (C) 2022-2026 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// </copyright>
// ------------------------------------------------------------------------------------------------

Expand All @@ -27,6 +27,7 @@ namespace SysML2.NET.Tests.Extend
using SysML2.NET.Core.POCO.Core.Types;
using SysML2.NET.Core.POCO.Root.Elements;
using SysML2.NET.Core.POCO.Root.Namespaces;
using SysML2.NET.Exceptions;
using SysML2.NET.Extensions;

using Type = SysML2.NET.Core.POCO.Core.Types.Type;
Expand All @@ -41,7 +42,7 @@ public void VerifyComputeTypeDifferenced()

var emptyDifferencing = new Differencing();

Assert.That(emptyDifferencing.ComputeTypeDifferenced(), Is.Null);
Assert.That(emptyDifferencing.ComputeTypeDifferenced, Throws.TypeOf<IncompleteModelException>());

var owningType = new Type();
var differencing = new Differencing();
Expand All @@ -55,7 +56,7 @@ public void VerifyComputeTypeDifferenced()

((IContainedRelationship)nonTypeDifferencing).OwningRelatedElement = nonTypeOwner;

Assert.That(nonTypeDifferencing.ComputeTypeDifferenced(), Is.Null);
Assert.That(nonTypeDifferencing.ComputeTypeDifferenced, Throws.TypeOf<IncompleteModelException>());
}
}
}
9 changes: 3 additions & 6 deletions SysML2.NET.Tests/Extend/ExpressionExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,8 @@ public void VerifyComputeModelLevelEvaluableOperation()

Assert.That(expressionNestedFeature.ComputeModelLevelEvaluableOperation([]), Is.False);

// ownedFeature with a FeatureValue — NOTE: the production code's valuation check
// (f.valuation == null) is a known metamodel gap (IFeature has no Valuation property).
// FeatureValue is IOwningMembership but NOT IFeatureMembership, so the contained Expression
// is not visible via ownedFeature of featureWithValuation. BRANCH_A therefore succeeds
// (Direction = In, ownedFeature.Count == 0) and the operation returns true.
// ownedFeature carrying a FeatureValue → BRANCH_A fails on the KerML §8.3.4.7.3 rule that a
// parameter must have no FeatureValue, and BRANCH_B fails (not a ResultExpressionMembership).
var expressionWithValuation = new Expression();
var featureWithValuation = new Feature { Direction = FeatureDirectionKind.In };
var featureValue = new FeatureValue();
Expand All @@ -232,7 +229,7 @@ public void VerifyComputeModelLevelEvaluableOperation()
var valuationMembership = new FeatureMembership();
expressionWithValuation.AssignOwnership(valuationMembership, featureWithValuation);

Assert.That(expressionWithValuation.ComputeModelLevelEvaluableOperation([]), Is.True);
Assert.That(expressionWithValuation.ComputeModelLevelEvaluableOperation([]), Is.False);

// BRANCH_B: ownedFeature owned via ResultExpressionMembership — passes branchB.
// The inner Expression is empty (no specializations, no features), so its recursive
Expand Down
17 changes: 9 additions & 8 deletions SysML2.NET.Tests/Extend/FeatureChainingExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="FeatureChainingExtensionsTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2026 Starion Group S.A.
//
//
// Copyright (C) 2022-2026 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// </copyright>
// ------------------------------------------------------------------------------------------------

Expand All @@ -27,6 +27,7 @@ namespace SysML2.NET.Tests.Extend
using SysML2.NET.Core.POCO.Core.Features;
using SysML2.NET.Core.POCO.Root.Elements;
using SysML2.NET.Core.POCO.Root.Namespaces;
using SysML2.NET.Exceptions;

[TestFixture]
public class FeatureChainingExtensionsTestFixture
Expand All @@ -38,7 +39,7 @@ public void VerifyComputeFeatureChained()

var featureChaining = new FeatureChaining();

Assert.That(featureChaining.ComputeFeatureChained(), Is.Null);
Assert.That(featureChaining.ComputeFeatureChained, Throws.TypeOf<IncompleteModelException>());

var feature = new Feature();

Expand All @@ -51,7 +52,7 @@ public void VerifyComputeFeatureChained()

((IContainedRelationship)nonFeatureChaining).OwningRelatedElement = nonFeatureOwner;

Assert.That(nonFeatureChaining.ComputeFeatureChained(), Is.Null);
Assert.That(nonFeatureChaining.ComputeFeatureChained, Throws.TypeOf<IncompleteModelException>());
}
}
}
23 changes: 17 additions & 6 deletions SysML2.NET.Tests/Extend/FeatureInvertingExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="FeatureInvertingExtensionsTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2026 Starion Group S.A.
//
//
// Copyright (C) 2022-2026 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// </copyright>
// ------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -44,8 +44,19 @@ public void VerifyComputeOwningFeature()

((IContainedRelationship)featureInverting).OwningRelatedElement = feature;

// owningFeature subsets featureInverted, so the owner must play that role to surface.
Assert.That(featureInverting.ComputeOwningFeature(), Is.Null);

featureInverting.FeatureInverted = feature;

Assert.That(featureInverting.ComputeOwningFeature(), Is.SameAs(feature));

featureInverting.FeatureInverted = new Feature();

Assert.That(featureInverting.ComputeOwningFeature(), Is.Null);

featureInverting.FeatureInverted = feature;

var nonFeatureOwner = new Namespace();
var nonFeatureInverting = new FeatureInverting();

Expand Down
23 changes: 17 additions & 6 deletions SysML2.NET.Tests/Extend/FeatureTypingExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="FeatureTypingExtensionsTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2026 Starion Group S.A.
//
//
// Copyright (C) 2022-2026 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// </copyright>
// ------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -44,8 +44,19 @@ public void VerifyComputeOwningFeature()

((IContainedRelationship)featureTyping).OwningRelatedElement = feature;

// owningFeature subsets typedFeature, so the owner must play that role to surface.
Assert.That(featureTyping.ComputeOwningFeature(), Is.Null);

featureTyping.TypedFeature = feature;

Assert.That(featureTyping.ComputeOwningFeature(), Is.SameAs(feature));

featureTyping.TypedFeature = new Feature();

Assert.That(featureTyping.ComputeOwningFeature(), Is.Null);

featureTyping.TypedFeature = feature;

var namespaceOwner = new Namespace();
var nonFeatureFeatureTyping = new FeatureTyping();

Expand Down
16 changes: 8 additions & 8 deletions SysML2.NET.Tests/Extend/FlowExtensionsTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="FlowExtensionsTestFixture.cs" company="Starion Group S.A.">
//
// Copyright 2022-2026 Starion Group S.A.
//
//
// Copyright (C) 2022-2026 Starion Group S.A.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// </copyright>
// ------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -211,7 +211,7 @@ public void VerifyComputeSourceOutputFeature()

Assert.That(flow.ComputeSourceOutputFeature(), Is.SameAs(innerFeatureA));

// Empty first end + non-empty second end → second end's first feature returned.
// Empty first end + non-empty second end → null; KerML §8.3.4.9.2 scopes the derivation to end 1.
var flow2 = new Flow();

var emptyEnd = new Feature { IsEnd = true };
Expand All @@ -226,7 +226,7 @@ public void VerifyComputeSourceOutputFeature()
var secondEndInnerMembership = new FeatureMembership();
nonEmptyEnd.AssignOwnership(secondEndInnerMembership, secondEndFeature);

Assert.That(flow2.ComputeSourceOutputFeature(), Is.SameAs(secondEndFeature));
Assert.That(flow2.ComputeSourceOutputFeature(), Is.Null);
}

[Test]
Expand Down
Loading
Loading