|
1 | 1 | // ------------------------------------------------------------------------------------------------- |
2 | 2 | // <copyright file="AcceptActionUsageExtensionsTestFixture.cs" company="Starion Group S.A."> |
3 | | -// |
| 3 | +// |
4 | 4 | // Copyright 2022-2026 Starion Group S.A. |
5 | | -// |
| 5 | +// |
6 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | // you may not use this file except in compliance with the License. |
8 | 8 | // You may obtain a copy of the License at |
9 | | -// |
| 9 | +// |
10 | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
11 | | -// |
| 11 | +// |
12 | 12 | // Unless required by applicable law or agreed to in writing, software |
13 | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
14 | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | 15 | // See the License for the specific language governing permissions and |
16 | 16 | // limitations under the License. |
17 | | -// |
| 17 | +// |
18 | 18 | // </copyright> |
19 | 19 | // ------------------------------------------------------------------------------------------------ |
20 | 20 |
|
21 | 21 | namespace SysML2.NET.Tests.Extend |
22 | 22 | { |
23 | 23 | using System; |
24 | | - |
| 24 | + |
25 | 25 | using NUnit.Framework; |
26 | | - |
| 26 | + |
| 27 | + using SysML2.NET.Core.POCO.Core.Types; |
27 | 28 | using SysML2.NET.Core.POCO.Systems.Actions; |
| 29 | + using SysML2.NET.Core.POCO.Systems.States; |
| 30 | + using SysML2.NET.Extensions; |
28 | 31 |
|
29 | 32 | [TestFixture] |
30 | 33 | public class AcceptActionUsageExtensionsTestFixture |
31 | 34 | { |
32 | 35 | [Test] |
33 | | - public void ComputePayloadArgument_ThrowsNotSupportedException() |
| 36 | + public void VerifyComputePayloadArgument() |
| 37 | + { |
| 38 | + Assert.That(() => ((IAcceptActionUsage)null).ComputePayloadArgument(), Throws.TypeOf<ArgumentNullException>()); |
| 39 | + |
| 40 | + var accept = new AcceptActionUsage(); |
| 41 | + |
| 42 | + // For Later: populated case depends on ActionUsageExtensions.ComputeArgumentOperation at SysML2.NET/Extend/ActionUsageExtensions.cs:157, which is still a stub. |
| 43 | + Assert.That(() => accept.ComputePayloadArgument(), Throws.TypeOf<NotSupportedException>()); |
| 44 | + } |
| 45 | + |
| 46 | + [Test] |
| 47 | + public void VerifyComputePayloadParameter() |
34 | 48 | { |
35 | | - Assert.That(() => ((IAcceptActionUsage)null).ComputePayloadArgument(), Throws.TypeOf<NotSupportedException>()); |
| 49 | + Assert.That(() => ((IAcceptActionUsage)null).ComputePayloadParameter(), Throws.TypeOf<ArgumentNullException>()); |
| 50 | + |
| 51 | + var accept = new AcceptActionUsage(); |
| 52 | + |
| 53 | + // For Later: populated case depends on StepExtensions.ComputeParameter at SysML2.NET/Extend/StepExtensions.cs:71, which is still a stub. |
| 54 | + Assert.That(() => accept.ComputePayloadParameter(), Throws.TypeOf<NotSupportedException>()); |
36 | 55 | } |
37 | | - |
| 56 | + |
38 | 57 | [Test] |
39 | | - public void ComputePayloadParameter_ThrowsNotSupportedException() |
| 58 | + public void VerifyComputeReceiverArgument() |
40 | 59 | { |
41 | | - Assert.That(() => ((IAcceptActionUsage)null).ComputePayloadParameter(), Throws.TypeOf<NotSupportedException>()); |
| 60 | + Assert.That(() => ((IAcceptActionUsage)null).ComputeReceiverArgument(), Throws.TypeOf<ArgumentNullException>()); |
| 61 | + |
| 62 | + var accept = new AcceptActionUsage(); |
| 63 | + |
| 64 | + // For Later: populated case depends on ActionUsageExtensions.ComputeArgumentOperation at SysML2.NET/Extend/ActionUsageExtensions.cs:157, which is still a stub. |
| 65 | + Assert.That(() => accept.ComputeReceiverArgument(), Throws.TypeOf<NotSupportedException>()); |
42 | 66 | } |
43 | | - |
| 67 | + |
44 | 68 | [Test] |
45 | | - public void ComputeReceiverArgument_ThrowsNotSupportedException() |
| 69 | + public void VerifyComputeIsTriggerActionOperation() |
46 | 70 | { |
47 | | - Assert.That(() => ((IAcceptActionUsage)null).ComputeReceiverArgument(), Throws.TypeOf<NotSupportedException>()); |
| 71 | + Assert.That(() => ((IAcceptActionUsage)null).ComputeIsTriggerActionOperation(), Throws.TypeOf<ArgumentNullException>()); |
| 72 | + |
| 73 | + // Branch A — null owningType: no OwningRelationship set, so owningType is null → false. |
| 74 | + var acceptNoOwner = new AcceptActionUsage(); |
| 75 | + |
| 76 | + Assert.That(acceptNoOwner.ComputeIsTriggerActionOperation(), Is.False); |
| 77 | + |
| 78 | + // Branch B — non-null owningType, not ITransitionUsage: owner is ActionDefinition → false. |
| 79 | + var actionDefinitionOwner = new ActionDefinition(); |
| 80 | + var featureMembershipB = new FeatureMembership(); |
| 81 | + actionDefinitionOwner.AssignOwnership(featureMembershipB, new AcceptActionUsage()); |
| 82 | + var acceptNotTransition = new AcceptActionUsage(); |
| 83 | + actionDefinitionOwner.AssignOwnership(new FeatureMembership(), acceptNotTransition); |
| 84 | + |
| 85 | + Assert.That(acceptNotTransition.ComputeIsTriggerActionOperation(), Is.False); |
| 86 | + |
| 87 | + // Branch C — owningType IS ITransitionUsage: triggerAction dispatch hits the ComputeTriggerAction stub. |
| 88 | + var transitionOwner = new TransitionUsage(); |
| 89 | + var featureMembershipC = new FeatureMembership(); |
| 90 | + var acceptInTransition = new AcceptActionUsage(); |
| 91 | + transitionOwner.AssignOwnership(featureMembershipC, acceptInTransition); |
| 92 | + |
| 93 | + // For Later: populated case depends on TransitionUsageExtensions.ComputeTriggerAction at SysML2.NET/Extend/TransitionUsageExtensions.cs:208, which is still a stub. |
| 94 | + Assert.That(() => acceptInTransition.ComputeIsTriggerActionOperation(), Throws.TypeOf<NotSupportedException>()); |
48 | 95 | } |
49 | 96 | } |
50 | 97 | } |
0 commit comments