Skip to content

Commit 967dddc

Browse files
1 parent 4dfa800 commit 967dddc

18 files changed

Lines changed: 204 additions & 109 deletions

SysML2.NET.Tests/Extend/ExpressionExtensionsTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="ExpressionExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.

SysML2.NET.Tests/Extend/IntersectingExtensionsTestFixture.cs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="IntersectingExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,18 +21,45 @@
2121
namespace SysML2.NET.Tests.Extend
2222
{
2323
using System;
24-
24+
2525
using NUnit.Framework;
26-
26+
2727
using SysML2.NET.Core.POCO.Core.Types;
28+
using SysML2.NET.Core.POCO.Root.Elements;
29+
using SysML2.NET.Core.POCO.Root.Namespaces;
30+
using SysML2.NET.Exceptions;
31+
32+
using Type = SysML2.NET.Core.POCO.Core.Types.Type;
2833

2934
[TestFixture]
3035
public class IntersectingExtensionsTestFixture
3136
{
3237
[Test]
33-
public void ComputeTypeIntersected_ThrowsNotSupportedException()
38+
public void VerifyComputeTypeIntersected()
3439
{
35-
Assert.That(() => ((IIntersecting)null).ComputeTypeIntersected(), Throws.TypeOf<NotSupportedException>());
40+
// Null subject → ArgumentNullException.
41+
Assert.That(() => ((IIntersecting)null).ComputeTypeIntersected(), Throws.TypeOf<ArgumentNullException>());
42+
43+
// Empty Intersecting (OwningRelatedElement is null) → [1..1] violation: IncompleteModelException.
44+
var emptyIntersecting = new Intersecting();
45+
46+
Assert.That(() => emptyIntersecting.ComputeTypeIntersected(), Throws.TypeOf<IncompleteModelException>());
47+
48+
// OwningRelatedElement is an IType → returns the same instance.
49+
var type = new Type();
50+
var intersectingWithType = new Intersecting();
51+
52+
((IContainedRelationship)intersectingWithType).OwningRelatedElement = type;
53+
54+
Assert.That(intersectingWithType.ComputeTypeIntersected(), Is.SameAs(type));
55+
56+
// OwningRelatedElement is a non-IType (Namespace) → [1..1] type violation: IncompleteModelException.
57+
var namespaceObj = new Namespace();
58+
var intersectingWithNamespace = new Intersecting();
59+
60+
((IContainedRelationship)intersectingWithNamespace).OwningRelatedElement = namespaceObj;
61+
62+
Assert.That(() => intersectingWithNamespace.ComputeTypeIntersected(), Throws.TypeOf<IncompleteModelException>());
3663
}
3764
}
3865
}

SysML2.NET.Tests/Extend/ObjectiveMembershipExtensionsTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="ObjectiveMembershipExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.

SysML2.NET.Tests/Extend/PortConjugationExtensionsTestFixture.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="PortConjugationExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,18 +21,42 @@
2121
namespace SysML2.NET.Tests.Extend
2222
{
2323
using System;
24-
24+
2525
using NUnit.Framework;
26-
26+
27+
using SysML2.NET.Core.POCO.Root.Elements;
2728
using SysML2.NET.Core.POCO.Systems.Ports;
29+
using SysML2.NET.Exceptions;
2830

2931
[TestFixture]
3032
public class PortConjugationExtensionsTestFixture
3133
{
3234
[Test]
33-
public void ComputeConjugatedPortDefinition_ThrowsNotSupportedException()
35+
public void VerifyComputeConjugatedPortDefinition()
3436
{
35-
Assert.That(() => ((IPortConjugation)null).ComputeConjugatedPortDefinition(), Throws.TypeOf<NotSupportedException>());
37+
// Null subject → ArgumentNullException.
38+
Assert.That(() => ((IPortConjugation)null).ComputeConjugatedPortDefinition(), Throws.TypeOf<ArgumentNullException>());
39+
40+
// Empty PortConjugation (OwningRelatedElement is null) → [1..1] violation: IncompleteModelException.
41+
var emptyPortConj = new PortConjugation();
42+
43+
Assert.That(() => emptyPortConj.ComputeConjugatedPortDefinition(), Throws.TypeOf<IncompleteModelException>());
44+
45+
// OwningRelatedElement is an IConjugatedPortDefinition → returns the same instance.
46+
var conjugated = new ConjugatedPortDefinition();
47+
var portConjWithConjugated = new PortConjugation();
48+
49+
((IContainedRelationship)portConjWithConjugated).OwningRelatedElement = conjugated;
50+
51+
Assert.That(portConjWithConjugated.ComputeConjugatedPortDefinition(), Is.SameAs(conjugated));
52+
53+
// OwningRelatedElement is a PortDefinition (IPortDefinition but NOT IConjugatedPortDefinition) → [1..1] type violation: IncompleteModelException.
54+
var portDefinition = new PortDefinition();
55+
var portConjWithPortDefinition = new PortConjugation();
56+
57+
((IContainedRelationship)portConjWithPortDefinition).OwningRelatedElement = portDefinition;
58+
59+
Assert.That(() => portConjWithPortDefinition.ComputeConjugatedPortDefinition(), Throws.TypeOf<IncompleteModelException>());
3660
}
3761
}
3862
}

SysML2.NET.Tests/Extend/ResultExpressionMembershipExtensionsTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="ResultExpressionMembershipExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.

SysML2.NET.Tests/Extend/StakeholderMembershipExtensionsTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="StakeholderMembershipExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.

SysML2.NET.Tests/Extend/StateSubactionMembershipExtensionsTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="StateSubactionMembershipExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.

SysML2.NET.Tests/Extend/StateUsageExtensionsTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="StateUsageExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.

SysML2.NET.Tests/Extend/TypeFeaturingExtensionsTestFixture.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="TypeFeaturingExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,18 +21,36 @@
2121
namespace SysML2.NET.Tests.Extend
2222
{
2323
using System;
24-
24+
2525
using NUnit.Framework;
26-
26+
2727
using SysML2.NET.Core.POCO.Core.Features;
28+
using SysML2.NET.Core.POCO.Root.Elements;
29+
using SysML2.NET.Core.POCO.Root.Namespaces;
2830

2931
[TestFixture]
3032
public class TypeFeaturingExtensionsTestFixture
3133
{
3234
[Test]
33-
public void ComputeOwningFeatureOfType_ThrowsNotSupportedException()
35+
public void VerifyComputeOwningFeatureOfType()
3436
{
35-
Assert.That(() => ((ITypeFeaturing)null).ComputeOwningFeatureOfType(), Throws.TypeOf<NotSupportedException>());
37+
Assert.That(() => ((ITypeFeaturing)null).ComputeOwningFeatureOfType(), Throws.TypeOf<ArgumentNullException>());
38+
39+
var typeFeaturing = new TypeFeaturing();
40+
41+
Assert.That(typeFeaturing.ComputeOwningFeatureOfType(), Is.Null);
42+
43+
var feature = new Feature();
44+
45+
((IContainedRelationship)typeFeaturing).OwningRelatedElement = feature;
46+
47+
Assert.That(typeFeaturing.ComputeOwningFeatureOfType(), Is.SameAs(feature));
48+
49+
var nonFeatureTypeFeaturing = new TypeFeaturing();
50+
51+
((IContainedRelationship)nonFeatureTypeFeaturing).OwningRelatedElement = new Namespace();
52+
53+
Assert.That(nonFeatureTypeFeaturing.ComputeOwningFeatureOfType(), Is.Null);
3654
}
3755
}
3856
}

SysML2.NET.Tests/Extend/UnioningExtensionsTestFixture.cs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -------------------------------------------------------------------------------------------------
22
// <copyright file="UnioningExtensionsTestFixture.cs" company="Starion Group S.A.">
33
//
4-
// Copyright 2022-2026 Starion Group S.A.
4+
// Copyright (C) 2022-2026 Starion Group S.A.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,18 +21,45 @@
2121
namespace SysML2.NET.Tests.Extend
2222
{
2323
using System;
24-
24+
2525
using NUnit.Framework;
26-
26+
2727
using SysML2.NET.Core.POCO.Core.Types;
28+
using SysML2.NET.Core.POCO.Root.Annotations;
29+
using SysML2.NET.Core.POCO.Root.Elements;
30+
using SysML2.NET.Exceptions;
31+
32+
using SysMLType = SysML2.NET.Core.POCO.Core.Types.Type;
2833

2934
[TestFixture]
3035
public class UnioningExtensionsTestFixture
3136
{
3237
[Test]
33-
public void ComputeTypeUnioned_ThrowsNotSupportedException()
38+
public void VerifyComputeTypeUnioned()
3439
{
35-
Assert.That(() => ((IUnioning)null).ComputeTypeUnioned(), Throws.TypeOf<NotSupportedException>());
40+
// Null subject → ArgumentNullException.
41+
Assert.That(() => ((IUnioning)null).ComputeTypeUnioned(), Throws.TypeOf<ArgumentNullException>());
42+
43+
// Empty Unioning (OwningRelatedElement is null) → [1..1] violation: IncompleteModelException.
44+
var emptyUnioning = new Unioning();
45+
46+
Assert.That(() => emptyUnioning.ComputeTypeUnioned(), Throws.TypeOf<IncompleteModelException>());
47+
48+
// OwningRelatedElement is an IType → returns the same instance.
49+
var type = new SysMLType();
50+
var unioningWithType = new Unioning();
51+
52+
((IContainedRelationship)unioningWithType).OwningRelatedElement = type;
53+
54+
Assert.That(unioningWithType.ComputeTypeUnioned(), Is.SameAs(type));
55+
56+
// OwningRelatedElement is a non-IType element (Annotation) → [1..1] type violation: IncompleteModelException.
57+
var annotation = new Annotation();
58+
var unioningWithAnnotation = new Unioning();
59+
60+
((IContainedRelationship)unioningWithAnnotation).OwningRelatedElement = annotation;
61+
62+
Assert.That(() => unioningWithAnnotation.ComputeTypeUnioned(), Throws.TypeOf<IncompleteModelException>());
3663
}
3764
}
3865
}

0 commit comments

Comments
 (0)