From 0a9690af1fc276041b4ba518d3e0ab7a76b23b31 Mon Sep 17 00:00:00 2001 From: samatstarion Date: Wed, 18 Feb 2026 10:32:12 +0100 Subject: [PATCH 1/2] [Add] test project for SysML2.NET [Add] testfixture for ElementExtensions --- .../ElementExtensionsTestFixture.cs | 85 +++++++++++++++++++ SysML2.NET.Tests/SysML2.NET.Tests.csproj | 45 ++++++++++ SysML2.NET.sln | 6 ++ 3 files changed, 136 insertions(+) create mode 100644 SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs create mode 100644 SysML2.NET.Tests/SysML2.NET.Tests.csproj diff --git a/SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs b/SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs new file mode 100644 index 00000000..059c6578 --- /dev/null +++ b/SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs @@ -0,0 +1,85 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 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. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Tests.Extensions +{ + using System; + using Core.POCO.Core.Features; + using Core.POCO.Core.Types; + using Core.POCO.Systems.Parts; + using NET.Extensions; + using NUnit.Framework; + + [TestFixture] + public class ElementExtensionsTestFixture + { + private PartDefinition source; + private FeatureMembership bridgeRelationship; + private Feature target; + + [SetUp] + public void SetUp() + { + source = new PartDefinition(); + bridgeRelationship = new FeatureMembership(); + target = new Feature(); + } + + [Test] + public void AssignOwnership_WithNullSource_ThrowsArgumentNullException() + { + Assert.Throws(() => ElementExtensions.AssignOwnership(null, bridgeRelationship, target)); + } + + [Test] + public void AssignOwnership_WithNullBridge_ThrowsArgumentNullException() + { + Assert.Throws(() => ElementExtensions.AssignOwnership(source, null, target)); + } + + [Test] + public void AssignOwnership_WithNullTarget_ThrowsArgumentNullException() + { + Assert.Throws(() => ElementExtensions.AssignOwnership(source, bridgeRelationship, null)); + } + + [Test] + public void AssignOwnership_WithSourceEqualsTarget_ThrowsInvalidOperationException() + { + Assert.Throws(() => ElementExtensions.AssignOwnership(source, bridgeRelationship, source)); + } + + [Test] + public void AssignOwnership_WithBridgeEqualsTarget_ThrowsInvalidOperationException() + { + Assert.Throws(() => ElementExtensions.AssignOwnership(source, bridgeRelationship, bridgeRelationship)); + } + + [Test] + public void AssignOwnership_WithValidParameters_AssignsOwnershipCorrectly() + { + ElementExtensions.AssignOwnership(source, bridgeRelationship, target); + + Assert.That(bridgeRelationship.OwningRelatedElement, Is.EqualTo(source)); + Assert.That(source.OwnedRelationship, Does.Contain(bridgeRelationship)); + Assert.That(bridgeRelationship.OwnedRelatedElement, Does.Contain(target)); + } + } +} diff --git a/SysML2.NET.Tests/SysML2.NET.Tests.csproj b/SysML2.NET.Tests/SysML2.NET.Tests.csproj new file mode 100644 index 00000000..054da954 --- /dev/null +++ b/SysML2.NET.Tests/SysML2.NET.Tests.csproj @@ -0,0 +1,45 @@ + + + + net10.0 + 12.0 + Starion Group S.A. + Sam Gerene + Nunit test suite for the SysML2.NET.Extensions Library + Copyright © Starion Group S.A. + Apache-2.0 + https://github.com/STARIONGROUP/SysML2.NET.git + Git + false + disable + false + true + en-US + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + diff --git a/SysML2.NET.sln b/SysML2.NET.sln index f97d22fe..e8c69e28 100644 --- a/SysML2.NET.sln +++ b/SysML2.NET.sln @@ -67,6 +67,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SysML2.NET.Kpar", "SysML2.N EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SysML2.NET.Kpar.Tests", "SysML2.NET.Kpar.Tests\SysML2.NET.Kpar.Tests.csproj", "{ACA8A0A2-EF4E-4F22-9164-07F6550F81F0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SysML2.NET.Tests", "SysML2.NET.Tests\SysML2.NET.Tests.csproj", "{C3953262-2718-4EC6-B7EB-BB94402D335A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -149,6 +151,10 @@ Global {ACA8A0A2-EF4E-4F22-9164-07F6550F81F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {ACA8A0A2-EF4E-4F22-9164-07F6550F81F0}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACA8A0A2-EF4E-4F22-9164-07F6550F81F0}.Release|Any CPU.Build.0 = Release|Any CPU + {C3953262-2718-4EC6-B7EB-BB94402D335A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3953262-2718-4EC6-B7EB-BB94402D335A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3953262-2718-4EC6-B7EB-BB94402D335A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3953262-2718-4EC6-B7EB-BB94402D335A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From be67882dc98ed103f179bdfc32e3b5da46eef90a Mon Sep 17 00:00:00 2001 From: samatstarion Date: Wed, 18 Feb 2026 10:54:10 +0100 Subject: [PATCH 2/2] [Implement] review suggestions --- .../ElementExtensionsTestFixture.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs b/SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs index 059c6578..ee3940e1 100644 --- a/SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs +++ b/SysML2.NET.Tests/Extensions/ElementExtensionsTestFixture.cs @@ -21,10 +21,12 @@ namespace SysML2.NET.Tests.Extensions { using System; - using Core.POCO.Core.Features; - using Core.POCO.Core.Types; - using Core.POCO.Systems.Parts; - using NET.Extensions; + + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Extensions; + using NUnit.Framework; [TestFixture] @@ -77,9 +79,12 @@ public void AssignOwnership_WithValidParameters_AssignsOwnershipCorrectly() { ElementExtensions.AssignOwnership(source, bridgeRelationship, target); - Assert.That(bridgeRelationship.OwningRelatedElement, Is.EqualTo(source)); - Assert.That(source.OwnedRelationship, Does.Contain(bridgeRelationship)); - Assert.That(bridgeRelationship.OwnedRelatedElement, Does.Contain(target)); + using (Assert.EnterMultipleScope()) + { + Assert.That(bridgeRelationship.OwningRelatedElement, Is.EqualTo(source)); + Assert.That(source.OwnedRelationship, Does.Contain(bridgeRelationship)); + Assert.That(bridgeRelationship.OwnedRelatedElement, Does.Contain(target)); + } } } }