diff --git a/SysML2.NET.Tests/Extend/AssignmentActionUsageExtensionsTestFixture.cs b/SysML2.NET.Tests/Extend/AssignmentActionUsageExtensionsTestFixture.cs index d150c046..5d01434b 100644 --- a/SysML2.NET.Tests/Extend/AssignmentActionUsageExtensionsTestFixture.cs +++ b/SysML2.NET.Tests/Extend/AssignmentActionUsageExtensionsTestFixture.cs @@ -1,7 +1,7 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // // -// 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. @@ -21,30 +21,131 @@ namespace SysML2.NET.Tests.Extend { using System; - + using NUnit.Framework; - + + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Kernel.FeatureValues; + using SysML2.NET.Core.POCO.Kernel.Metadata; + using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Extensions; [TestFixture] public class AssignmentActionUsageExtensionsTestFixture { [Test] - public void ComputeReferent_ThrowsNotSupportedException() + public void VerifyComputeReferent() { - Assert.That(() => ((IAssignmentActionUsage)null).ComputeReferent(), Throws.TypeOf()); + Assert.That(() => ((IAssignmentActionUsage)null).ComputeReferent(), Throws.TypeOf()); + + // No ownedMembership at all -> null. + var empty = new AssignmentActionUsage(); + + // A feature owned via a FeatureMembership is rejected by reject(FeatureMembership) -> null. + var featureMembershipOnly = new AssignmentActionUsage(); + featureMembershipOnly.AssignOwnership(new FeatureMembership(), new Feature()); + + // A non-FeatureMembership membership whose memberElement is a MetadataFeature is excluded + // by the 'not MetadataFeature' filter -> null. + var metadataOnly = new AssignmentActionUsage(); + var metadataMembership = new Membership(); + metadataOnly.AssignOwnership(metadataMembership); + metadataMembership.MemberElement = new MetadataFeature(); + + // A non-FeatureMembership membership whose memberElement is a plain Feature -> returned. + var referentFeature = new Feature(); + var positive = new AssignmentActionUsage(); + var referentMembership = new Membership(); + positive.AssignOwnership(referentMembership); + referentMembership.MemberElement = referentFeature; + + // Ordering: the first qualifying membership in ownedMembership order wins. + var firstFeature = new Feature(); + var secondFeature = new Feature(); + var ordered = new AssignmentActionUsage(); + var firstMembership = new Membership(); + ordered.AssignOwnership(firstMembership); + firstMembership.MemberElement = firstFeature; + var secondMembership = new Membership(); + ordered.AssignOwnership(secondMembership); + secondMembership.MemberElement = secondFeature; + + using (Assert.EnterMultipleScope()) + { + Assert.That(empty.ComputeReferent(), Is.Null); + Assert.That(featureMembershipOnly.ComputeReferent(), Is.Null); + Assert.That(metadataOnly.ComputeReferent(), Is.Null); + Assert.That(positive.ComputeReferent(), Is.SameAs(referentFeature)); + Assert.That(ordered.ComputeReferent(), Is.SameAs(firstFeature)); + } } - + [Test] - public void ComputeTargetArgument_ThrowsNotSupportedException() + public void VerifyComputeTargetArgument() { - Assert.That(() => ((IAssignmentActionUsage)null).ComputeTargetArgument(), Throws.TypeOf()); + Assert.That(() => ((IAssignmentActionUsage)null).ComputeTargetArgument(), Throws.TypeOf()); + + // No input parameters -> argument(1) is null -> null. + Assert.That(new AssignmentActionUsage().ComputeTargetArgument(), Is.Null); + + var targetExpression = new LiteralInteger(); + var valueExpression = new LiteralInteger(); + var assignmentActionUsage = CreateAssignmentActionUsageWithArguments(targetExpression, valueExpression); + + using (Assert.EnterMultipleScope()) + { + // targetArgument = argument(1) + Assert.That(assignmentActionUsage.ComputeTargetArgument(), Is.SameAs(targetExpression)); + Assert.That(assignmentActionUsage.ComputeTargetArgument(), Is.Not.SameAs(valueExpression)); + } } - + [Test] - public void ComputeValueExpression_ThrowsNotSupportedException() + public void VerifyComputeValueExpression() { - Assert.That(() => ((IAssignmentActionUsage)null).ComputeValueExpression(), Throws.TypeOf()); + Assert.That(() => ((IAssignmentActionUsage)null).ComputeValueExpression(), Throws.TypeOf()); + + // No input parameters -> argument(2) is null -> null. + Assert.That(new AssignmentActionUsage().ComputeValueExpression(), Is.Null); + + var targetExpression = new LiteralInteger(); + var valueExpression = new LiteralInteger(); + var assignmentActionUsage = CreateAssignmentActionUsageWithArguments(targetExpression, valueExpression); + + // Only a single input parameter present -> argument(2) is out of range -> null. + var singleArgumentAssignmentActionUsage = CreateAssignmentActionUsageWithArguments(new LiteralInteger()); + + using (Assert.EnterMultipleScope()) + { + // valueExpression = argument(2) + Assert.That(assignmentActionUsage.ComputeValueExpression(), Is.SameAs(valueExpression)); + Assert.That(assignmentActionUsage.ComputeValueExpression(), Is.Not.SameAs(targetExpression)); + Assert.That(singleArgumentAssignmentActionUsage.ComputeValueExpression(), Is.Null); + } + } + + /// + /// Builds an whose i-th owned input parameter carries a + /// whose value is the i-th supplied argument expression, so that + /// Argument(i) resolves to that expression. + /// + private static AssignmentActionUsage CreateAssignmentActionUsageWithArguments(params LiteralInteger[] argumentExpressions) + { + var assignmentActionUsage = new AssignmentActionUsage(); + + foreach (var argumentExpression in argumentExpressions) + { + var inputParameter = new ReferenceUsage { Direction = FeatureDirectionKind.In }; + assignmentActionUsage.AssignOwnership(new FeatureMembership(), inputParameter); + inputParameter.AssignOwnership(new FeatureValue(), argumentExpression); + } + + return assignmentActionUsage; } } } diff --git a/SysML2.NET.Tests/Extend/IfActionUsageExtensionsTestFixture.cs b/SysML2.NET.Tests/Extend/IfActionUsageExtensionsTestFixture.cs index 5b16655f..46832b97 100644 --- a/SysML2.NET.Tests/Extend/IfActionUsageExtensionsTestFixture.cs +++ b/SysML2.NET.Tests/Extend/IfActionUsageExtensionsTestFixture.cs @@ -1,7 +1,7 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // // -// 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. @@ -21,30 +21,107 @@ namespace SysML2.NET.Tests.Extend { using System; - + using NUnit.Framework; - + + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Expressions; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Extensions; [TestFixture] public class IfActionUsageExtensionsTestFixture { [Test] - public void ComputeElseAction_ThrowsNotSupportedException() + public void VerifyComputeElseAction() { - Assert.That(() => ((IIfActionUsage)null).ComputeElseAction(), Throws.TypeOf()); + Assert.That(() => ((IIfActionUsage)null).ComputeElseAction(), Throws.TypeOf()); + + // No input parameters -> inputParameter(3) is null -> null. + Assert.That(new IfActionUsage().ComputeElseAction(), Is.Null); + + // Only two input parameters -> inputParameter(3) is out of range -> null. + var twoParameterIfActionUsage = CreateIfActionUsageWithInputParameters(new LiteralInteger(), new ActionUsage()); + + // inputParameter(3) present and IS an IActionUsage -> returned. + var elseAction = new ActionUsage(); + var ifActionUsage = CreateIfActionUsageWithInputParameters(new LiteralInteger(), new ActionUsage(), elseAction); + + using (Assert.EnterMultipleScope()) + { + Assert.That(twoParameterIfActionUsage.ComputeElseAction(), Is.Null); + + // elseAction = inputParameter(3) as ActionUsage + Assert.That(ifActionUsage.ComputeElseAction(), Is.SameAs(elseAction)); + } } - + [Test] - public void ComputeIfArgument_ThrowsNotSupportedException() + public void VerifyComputeIfArgument() { - Assert.That(() => ((IIfActionUsage)null).ComputeIfArgument(), Throws.TypeOf()); + Assert.That(() => ((IIfActionUsage)null).ComputeIfArgument(), Throws.TypeOf()); + + // No input parameters -> inputParameter(1) is null -> null. + Assert.That(new IfActionUsage().ComputeIfArgument(), Is.Null); + + // inputParameter(1) present but NOT an IExpression -> the 'as IExpression' filter yields null. + var wrongTypeIfActionUsage = CreateIfActionUsageWithInputParameters(new ReferenceUsage()); + + // inputParameter(1) present and IS an IExpression -> returned. + var ifExpression = new LiteralInteger(); + var ifActionUsage = CreateIfActionUsageWithInputParameters(ifExpression, new ActionUsage(), new ActionUsage()); + + using (Assert.EnterMultipleScope()) + { + Assert.That(wrongTypeIfActionUsage.ComputeIfArgument(), Is.Null); + + // ifArgument = inputParameter(1) as Expression + Assert.That(ifActionUsage.ComputeIfArgument(), Is.SameAs(ifExpression)); + } } - + [Test] - public void ComputeThenAction_ThrowsNotSupportedException() + public void VerifyComputeThenAction() + { + Assert.That(() => ((IIfActionUsage)null).ComputeThenAction(), Throws.TypeOf()); + + // No input parameters -> inputParameter(2) is null -> null. + Assert.That(new IfActionUsage().ComputeThenAction(), Is.Null); + + // inputParameter(2) present but NOT an IActionUsage -> the 'as IActionUsage' filter yields null. + var wrongTypeIfActionUsage = CreateIfActionUsageWithInputParameters(new LiteralInteger(), new ReferenceUsage()); + + // inputParameter(2) present and IS an IActionUsage -> returned. + var thenAction = new ActionUsage(); + var ifActionUsage = CreateIfActionUsageWithInputParameters(new LiteralInteger(), thenAction, new ActionUsage()); + + using (Assert.EnterMultipleScope()) + { + Assert.That(wrongTypeIfActionUsage.ComputeThenAction(), Is.Null); + + // thenAction = inputParameter(2) as ActionUsage + Assert.That(ifActionUsage.ComputeThenAction(), Is.SameAs(thenAction)); + } + } + + /// + /// Builds an owning the supplied features as ordered input parameters + /// (Direction = In), so that InputParameter(i) resolves to the i-th supplied feature. + /// + private static IfActionUsage CreateIfActionUsageWithInputParameters(params IFeature[] inputParameters) { - Assert.That(() => ((IIfActionUsage)null).ComputeThenAction(), Throws.TypeOf()); + var ifActionUsage = new IfActionUsage(); + + foreach (var inputParameter in inputParameters) + { + inputParameter.Direction = FeatureDirectionKind.In; + ifActionUsage.AssignOwnership(new FeatureMembership(), inputParameter); + } + + return ifActionUsage; } } } diff --git a/SysML2.NET.Tests/Extend/SendActionUsageExtensionsTestFixture.cs b/SysML2.NET.Tests/Extend/SendActionUsageExtensionsTestFixture.cs index f39d61bf..605cb087 100644 --- a/SysML2.NET.Tests/Extend/SendActionUsageExtensionsTestFixture.cs +++ b/SysML2.NET.Tests/Extend/SendActionUsageExtensionsTestFixture.cs @@ -1,7 +1,7 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // // -// 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. @@ -21,30 +21,105 @@ namespace SysML2.NET.Tests.Extend { using System; - + using NUnit.Framework; - + + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Kernel.FeatureValues; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Extensions; [TestFixture] public class SendActionUsageExtensionsTestFixture { [Test] - public void ComputePayloadArgument_ThrowsNotSupportedException() + public void VerifyComputePayloadArgument() { - Assert.That(() => ((ISendActionUsage)null).ComputePayloadArgument(), Throws.TypeOf()); + Assert.That(() => ((ISendActionUsage)null).ComputePayloadArgument(), Throws.TypeOf()); + + Assert.That(new SendActionUsage().ComputePayloadArgument(), Is.Null); + + var payloadExpression = new LiteralInteger(); + var senderExpression = new LiteralInteger(); + var receiverExpression = new LiteralInteger(); + var sendActionUsage = CreateSendActionUsageWithArguments(payloadExpression, senderExpression, receiverExpression); + + using (Assert.EnterMultipleScope()) + { + // payloadArgument = argument(1) + Assert.That(sendActionUsage.ComputePayloadArgument(), Is.SameAs(payloadExpression)); + Assert.That(sendActionUsage.ComputePayloadArgument(), Is.Not.SameAs(senderExpression)); + } } - + [Test] - public void ComputeReceiverArgument_ThrowsNotSupportedException() + public void VerifyComputeReceiverArgument() { - Assert.That(() => ((ISendActionUsage)null).ComputeReceiverArgument(), Throws.TypeOf()); + Assert.That(() => ((ISendActionUsage)null).ComputeReceiverArgument(), Throws.TypeOf()); + + Assert.That(new SendActionUsage().ComputeReceiverArgument(), Is.Null); + + var payloadExpression = new LiteralInteger(); + var senderExpression = new LiteralInteger(); + var receiverExpression = new LiteralInteger(); + var sendActionUsage = CreateSendActionUsageWithArguments(payloadExpression, senderExpression, receiverExpression); + + // Only two input parameters present -> argument(3) is out of range -> null. + var twoArgumentSendActionUsage = CreateSendActionUsageWithArguments(new LiteralInteger(), new LiteralInteger()); + + using (Assert.EnterMultipleScope()) + { + // receiverArgument = argument(3) + Assert.That(sendActionUsage.ComputeReceiverArgument(), Is.SameAs(receiverExpression)); + Assert.That(sendActionUsage.ComputeReceiverArgument(), Is.Not.SameAs(senderExpression)); + Assert.That(twoArgumentSendActionUsage.ComputeReceiverArgument(), Is.Null); + } } - + [Test] - public void ComputeSenderArgument_ThrowsNotSupportedException() + public void VerifyComputeSenderArgument() + { + Assert.That(() => ((ISendActionUsage)null).ComputeSenderArgument(), Throws.TypeOf()); + + Assert.That(new SendActionUsage().ComputeSenderArgument(), Is.Null); + + var payloadExpression = new LiteralInteger(); + var senderExpression = new LiteralInteger(); + var receiverExpression = new LiteralInteger(); + var sendActionUsage = CreateSendActionUsageWithArguments(payloadExpression, senderExpression, receiverExpression); + + // Only a single input parameter present -> argument(2) is out of range -> null. + var singleArgumentSendActionUsage = CreateSendActionUsageWithArguments(new LiteralInteger()); + + using (Assert.EnterMultipleScope()) + { + // senderArgument = argument(2) + Assert.That(sendActionUsage.ComputeSenderArgument(), Is.SameAs(senderExpression)); + Assert.That(sendActionUsage.ComputeSenderArgument(), Is.Not.SameAs(payloadExpression)); + Assert.That(singleArgumentSendActionUsage.ComputeSenderArgument(), Is.Null); + } + } + + /// + /// Builds a whose i-th owned input parameter carries a + /// whose value is the i-th supplied argument expression, so that + /// Argument(i) (and therefore each Compute* under test) resolves to that expression. + /// + private static SendActionUsage CreateSendActionUsageWithArguments(params LiteralInteger[] argumentExpressions) { - Assert.That(() => ((ISendActionUsage)null).ComputeSenderArgument(), Throws.TypeOf()); + var sendActionUsage = new SendActionUsage(); + + foreach (var argumentExpression in argumentExpressions) + { + var inputParameter = new ReferenceUsage { Direction = FeatureDirectionKind.In }; + sendActionUsage.AssignOwnership(new FeatureMembership(), inputParameter); + inputParameter.AssignOwnership(new FeatureValue(), argumentExpression); + } + + return sendActionUsage; } } } diff --git a/SysML2.NET.Tests/Extend/TerminateActionUsageExtensionsTestFixture.cs b/SysML2.NET.Tests/Extend/TerminateActionUsageExtensionsTestFixture.cs index 547e5dd2..f3366302 100644 --- a/SysML2.NET.Tests/Extend/TerminateActionUsageExtensionsTestFixture.cs +++ b/SysML2.NET.Tests/Extend/TerminateActionUsageExtensionsTestFixture.cs @@ -1,7 +1,7 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // // -// 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. @@ -21,18 +21,38 @@ namespace SysML2.NET.Tests.Extend { using System; - + using NUnit.Framework; - + + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Kernel.FeatureValues; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Extensions; [TestFixture] public class TerminateActionUsageExtensionsTestFixture { [Test] - public void ComputeTerminatedOccurrenceArgument_ThrowsNotSupportedException() + public void VerifyComputeTerminatedOccurrenceArgument() { - Assert.That(() => ((ITerminateActionUsage)null).ComputeTerminatedOccurrenceArgument(), Throws.TypeOf()); + Assert.That(() => ((ITerminateActionUsage)null).ComputeTerminatedOccurrenceArgument(), Throws.TypeOf()); + + // No input parameters -> argument(1) is null -> null. + Assert.That(new TerminateActionUsage().ComputeTerminatedOccurrenceArgument(), Is.Null); + + // A single owned input parameter carrying a FeatureValue -> argument(1) resolves to its value. + var terminateActionUsage = new TerminateActionUsage(); + var inputParameter = new ReferenceUsage { Direction = FeatureDirectionKind.In }; + terminateActionUsage.AssignOwnership(new FeatureMembership(), inputParameter); + + var terminatedOccurrenceExpression = new LiteralInteger(); + inputParameter.AssignOwnership(new FeatureValue(), terminatedOccurrenceExpression); + + // terminatedOccurrenceArgument = argument(1) + Assert.That(terminateActionUsage.ComputeTerminatedOccurrenceArgument(), Is.SameAs(terminatedOccurrenceExpression)); } } } diff --git a/SysML2.NET/Extend/AssignmentActionUsageExtensions.cs b/SysML2.NET/Extend/AssignmentActionUsageExtensions.cs index c246bc8e..b8bd7fa9 100644 --- a/SysML2.NET/Extend/AssignmentActionUsageExtensions.cs +++ b/SysML2.NET/Extend/AssignmentActionUsageExtensions.cs @@ -1,65 +1,36 @@ // ------------------------------------------------------------------------------------------------- // -// -// 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 -// +// +// 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. -// +// // // ------------------------------------------------------------------------------------------------ namespace SysML2.NET.Core.POCO.Systems.Actions { using System; - using System.Collections.Generic; + using System.Linq; - using SysML2.NET.Core.Core.Types; - using SysML2.NET.Core.Root.Namespaces; - using SysML2.NET.Core.Systems.Occurrences; - using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; - using SysML2.NET.Core.POCO.Kernel.Behaviors; - using SysML2.NET.Core.POCO.Kernel.Classes; using SysML2.NET.Core.POCO.Kernel.Functions; - using SysML2.NET.Core.POCO.Root.Annotations; - using SysML2.NET.Core.POCO.Root.Elements; - using SysML2.NET.Core.POCO.Root.Namespaces; - using SysML2.NET.Core.POCO.Systems.Allocations; - using SysML2.NET.Core.POCO.Systems.AnalysisCases; - using SysML2.NET.Core.POCO.Systems.Attributes; - using SysML2.NET.Core.POCO.Systems.Calculations; - using SysML2.NET.Core.POCO.Systems.Cases; - using SysML2.NET.Core.POCO.Systems.Connections; - using SysML2.NET.Core.POCO.Systems.Constraints; - using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; - using SysML2.NET.Core.POCO.Systems.Enumerations; - using SysML2.NET.Core.POCO.Systems.Flows; - using SysML2.NET.Core.POCO.Systems.Interfaces; - using SysML2.NET.Core.POCO.Systems.Items; - using SysML2.NET.Core.POCO.Systems.Metadata; - using SysML2.NET.Core.POCO.Systems.Occurrences; - using SysML2.NET.Core.POCO.Systems.Parts; - using SysML2.NET.Core.POCO.Systems.Ports; - using SysML2.NET.Core.POCO.Systems.Requirements; - using SysML2.NET.Core.POCO.Systems.States; - using SysML2.NET.Core.POCO.Systems.UseCases; - using SysML2.NET.Core.POCO.Systems.VerificationCases; - using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Kernel.Metadata; /// - /// The class provides extensions methods for - /// the interface + /// The class provides extensions methods for + /// the interface /// internal static class AssignmentActionUsageExtensions { @@ -80,30 +51,44 @@ internal static class AssignmentActionUsageExtensions /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IFeature ComputeReferent(this IAssignmentActionUsage assignmentActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + if (assignmentActionUsageSubject == null) + { + throw new ArgumentNullException(nameof(assignmentActionUsageSubject)); + } + + return assignmentActionUsageSubject.ownedMembership + .Where(membership => membership is not IFeatureMembership) + .Select(membership => membership.MemberElement) + .FirstOrDefault(memberElement => memberElement is IFeature and not IMetadataFeature) as IFeature; } /// /// Computes the derived property. /// + /// + /// OCL2.0: + /// + /// targetArgument = argument(1) + /// + /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IExpression ComputeTargetArgument(this IAssignmentActionUsage assignmentActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return assignmentActionUsageSubject == null + ? throw new ArgumentNullException(nameof(assignmentActionUsageSubject)) + : assignmentActionUsageSubject.Argument(1); } /// @@ -116,16 +101,16 @@ internal static IExpression ComputeTargetArgument(this IAssignmentActionUsage as /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IExpression ComputeValueExpression(this IAssignmentActionUsage assignmentActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return assignmentActionUsageSubject == null + ? throw new ArgumentNullException(nameof(assignmentActionUsageSubject)) + : assignmentActionUsageSubject.Argument(2); } - } } diff --git a/SysML2.NET/Extend/IfActionUsageExtensions.cs b/SysML2.NET/Extend/IfActionUsageExtensions.cs index bdfc90cd..01c4f73a 100644 --- a/SysML2.NET/Extend/IfActionUsageExtensions.cs +++ b/SysML2.NET/Extend/IfActionUsageExtensions.cs @@ -1,65 +1,32 @@ // ------------------------------------------------------------------------------------------------- // -// -// 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 -// +// +// 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. -// +// // // ------------------------------------------------------------------------------------------------ namespace SysML2.NET.Core.POCO.Systems.Actions { using System; - using System.Collections.Generic; - using SysML2.NET.Core.Core.Types; - using SysML2.NET.Core.Root.Namespaces; - using SysML2.NET.Core.Systems.Occurrences; - using SysML2.NET.Core.POCO.Core.Classifiers; - using SysML2.NET.Core.POCO.Core.Features; - using SysML2.NET.Core.POCO.Core.Types; - using SysML2.NET.Core.POCO.Kernel.Behaviors; - using SysML2.NET.Core.POCO.Kernel.Classes; using SysML2.NET.Core.POCO.Kernel.Functions; - using SysML2.NET.Core.POCO.Root.Annotations; - using SysML2.NET.Core.POCO.Root.Elements; - using SysML2.NET.Core.POCO.Root.Namespaces; - using SysML2.NET.Core.POCO.Systems.Allocations; - using SysML2.NET.Core.POCO.Systems.AnalysisCases; - using SysML2.NET.Core.POCO.Systems.Attributes; - using SysML2.NET.Core.POCO.Systems.Calculations; - using SysML2.NET.Core.POCO.Systems.Cases; - using SysML2.NET.Core.POCO.Systems.Connections; - using SysML2.NET.Core.POCO.Systems.Constraints; - using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; - using SysML2.NET.Core.POCO.Systems.Enumerations; - using SysML2.NET.Core.POCO.Systems.Flows; - using SysML2.NET.Core.POCO.Systems.Interfaces; - using SysML2.NET.Core.POCO.Systems.Items; - using SysML2.NET.Core.POCO.Systems.Metadata; - using SysML2.NET.Core.POCO.Systems.Occurrences; - using SysML2.NET.Core.POCO.Systems.Parts; - using SysML2.NET.Core.POCO.Systems.Ports; - using SysML2.NET.Core.POCO.Systems.Requirements; - using SysML2.NET.Core.POCO.Systems.States; - using SysML2.NET.Core.POCO.Systems.UseCases; - using SysML2.NET.Core.POCO.Systems.VerificationCases; - using SysML2.NET.Core.POCO.Systems.Views; /// - /// The class provides extensions methods for - /// the interface + /// The class provides extensions methods for + /// the interface /// internal static class IfActionUsageExtensions { @@ -79,15 +46,16 @@ internal static class IfActionUsageExtensions /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IActionUsage ComputeElseAction(this IIfActionUsage ifActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return ifActionUsageSubject == null + ? throw new ArgumentNullException(nameof(ifActionUsageSubject)) + : ifActionUsageSubject.InputParameter(3) as IActionUsage; } /// @@ -106,15 +74,16 @@ internal static IActionUsage ComputeElseAction(this IIfActionUsage ifActionUsage /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IExpression ComputeIfArgument(this IIfActionUsage ifActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return ifActionUsageSubject == null + ? throw new ArgumentNullException(nameof(ifActionUsageSubject)) + : ifActionUsageSubject.InputParameter(1) as IExpression; } /// @@ -133,16 +102,16 @@ internal static IExpression ComputeIfArgument(this IIfActionUsage ifActionUsageS /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IActionUsage ComputeThenAction(this IIfActionUsage ifActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return ifActionUsageSubject == null + ? throw new ArgumentNullException(nameof(ifActionUsageSubject)) + : ifActionUsageSubject.InputParameter(2) as IActionUsage; } - } } diff --git a/SysML2.NET/Extend/SendActionUsageExtensions.cs b/SysML2.NET/Extend/SendActionUsageExtensions.cs index 48cd617b..6c7e933c 100644 --- a/SysML2.NET/Extend/SendActionUsageExtensions.cs +++ b/SysML2.NET/Extend/SendActionUsageExtensions.cs @@ -1,65 +1,32 @@ // ------------------------------------------------------------------------------------------------- // -// -// 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 -// +// +// 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. -// +// // // ------------------------------------------------------------------------------------------------ namespace SysML2.NET.Core.POCO.Systems.Actions { using System; - using System.Collections.Generic; - using SysML2.NET.Core.Core.Types; - using SysML2.NET.Core.Root.Namespaces; - using SysML2.NET.Core.Systems.Occurrences; - using SysML2.NET.Core.POCO.Core.Classifiers; - using SysML2.NET.Core.POCO.Core.Features; - using SysML2.NET.Core.POCO.Core.Types; - using SysML2.NET.Core.POCO.Kernel.Behaviors; - using SysML2.NET.Core.POCO.Kernel.Classes; using SysML2.NET.Core.POCO.Kernel.Functions; - using SysML2.NET.Core.POCO.Root.Annotations; - using SysML2.NET.Core.POCO.Root.Elements; - using SysML2.NET.Core.POCO.Root.Namespaces; - using SysML2.NET.Core.POCO.Systems.Allocations; - using SysML2.NET.Core.POCO.Systems.AnalysisCases; - using SysML2.NET.Core.POCO.Systems.Attributes; - using SysML2.NET.Core.POCO.Systems.Calculations; - using SysML2.NET.Core.POCO.Systems.Cases; - using SysML2.NET.Core.POCO.Systems.Connections; - using SysML2.NET.Core.POCO.Systems.Constraints; - using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; - using SysML2.NET.Core.POCO.Systems.Enumerations; - using SysML2.NET.Core.POCO.Systems.Flows; - using SysML2.NET.Core.POCO.Systems.Interfaces; - using SysML2.NET.Core.POCO.Systems.Items; - using SysML2.NET.Core.POCO.Systems.Metadata; - using SysML2.NET.Core.POCO.Systems.Occurrences; - using SysML2.NET.Core.POCO.Systems.Parts; - using SysML2.NET.Core.POCO.Systems.Ports; - using SysML2.NET.Core.POCO.Systems.Requirements; - using SysML2.NET.Core.POCO.Systems.States; - using SysML2.NET.Core.POCO.Systems.UseCases; - using SysML2.NET.Core.POCO.Systems.VerificationCases; - using SysML2.NET.Core.POCO.Systems.Views; /// - /// The class provides extensions methods for - /// the interface + /// The class provides extensions methods for + /// the interface /// internal static class SendActionUsageExtensions { @@ -73,15 +40,16 @@ internal static class SendActionUsageExtensions /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IExpression ComputePayloadArgument(this ISendActionUsage sendActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return sendActionUsageSubject == null + ? throw new ArgumentNullException(nameof(sendActionUsageSubject)) + : sendActionUsageSubject.Argument(1); } /// @@ -94,15 +62,16 @@ internal static IExpression ComputePayloadArgument(this ISendActionUsage sendAct /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IExpression ComputeReceiverArgument(this ISendActionUsage sendActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return sendActionUsageSubject == null + ? throw new ArgumentNullException(nameof(sendActionUsageSubject)) + : sendActionUsageSubject.Argument(3); } /// @@ -115,16 +84,16 @@ internal static IExpression ComputeReceiverArgument(this ISendActionUsage sendAc /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IExpression ComputeSenderArgument(this ISendActionUsage sendActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return sendActionUsageSubject == null + ? throw new ArgumentNullException(nameof(sendActionUsageSubject)) + : sendActionUsageSubject.Argument(2); } - } } diff --git a/SysML2.NET/Extend/TerminateActionUsageExtensions.cs b/SysML2.NET/Extend/TerminateActionUsageExtensions.cs index a021ff1d..0a9beb2d 100644 --- a/SysML2.NET/Extend/TerminateActionUsageExtensions.cs +++ b/SysML2.NET/Extend/TerminateActionUsageExtensions.cs @@ -1,65 +1,32 @@ // ------------------------------------------------------------------------------------------------- // -// -// 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 -// +// +// 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. -// +// // // ------------------------------------------------------------------------------------------------ namespace SysML2.NET.Core.POCO.Systems.Actions { using System; - using System.Collections.Generic; - using SysML2.NET.Core.Core.Types; - using SysML2.NET.Core.Root.Namespaces; - using SysML2.NET.Core.Systems.Occurrences; - using SysML2.NET.Core.POCO.Core.Classifiers; - using SysML2.NET.Core.POCO.Core.Features; - using SysML2.NET.Core.POCO.Core.Types; - using SysML2.NET.Core.POCO.Kernel.Behaviors; - using SysML2.NET.Core.POCO.Kernel.Classes; using SysML2.NET.Core.POCO.Kernel.Functions; - using SysML2.NET.Core.POCO.Root.Annotations; - using SysML2.NET.Core.POCO.Root.Elements; - using SysML2.NET.Core.POCO.Root.Namespaces; - using SysML2.NET.Core.POCO.Systems.Allocations; - using SysML2.NET.Core.POCO.Systems.AnalysisCases; - using SysML2.NET.Core.POCO.Systems.Attributes; - using SysML2.NET.Core.POCO.Systems.Calculations; - using SysML2.NET.Core.POCO.Systems.Cases; - using SysML2.NET.Core.POCO.Systems.Connections; - using SysML2.NET.Core.POCO.Systems.Constraints; - using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; - using SysML2.NET.Core.POCO.Systems.Enumerations; - using SysML2.NET.Core.POCO.Systems.Flows; - using SysML2.NET.Core.POCO.Systems.Interfaces; - using SysML2.NET.Core.POCO.Systems.Items; - using SysML2.NET.Core.POCO.Systems.Metadata; - using SysML2.NET.Core.POCO.Systems.Occurrences; - using SysML2.NET.Core.POCO.Systems.Parts; - using SysML2.NET.Core.POCO.Systems.Ports; - using SysML2.NET.Core.POCO.Systems.Requirements; - using SysML2.NET.Core.POCO.Systems.States; - using SysML2.NET.Core.POCO.Systems.UseCases; - using SysML2.NET.Core.POCO.Systems.VerificationCases; - using SysML2.NET.Core.POCO.Systems.Views; /// - /// The class provides extensions methods for - /// the interface + /// The class provides extensions methods for + /// the interface /// internal static class TerminateActionUsageExtensions { @@ -73,16 +40,16 @@ internal static class TerminateActionUsageExtensions /// /// /// - /// The subject + /// The subject /// /// /// the computed result /// - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static IExpression ComputeTerminatedOccurrenceArgument(this ITerminateActionUsage terminateActionUsageSubject) { - throw new NotSupportedException("Create a GitHub issue when this method is required"); + return terminateActionUsageSubject == null + ? throw new ArgumentNullException(nameof(terminateActionUsageSubject)) + : terminateActionUsageSubject.Argument(1); } - } }