|
1 | 1 | // ------------------------------------------------------------------------------------------------- |
2 | 2 | // <copyright file="AttributeUsageExtensionsTestFixture.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.Systems.Attributes ; |
| 27 | + using SysML2.NET.Core.POCO.Core.Classifiers; |
| 28 | + using SysML2.NET.Core.POCO.Core.Features; |
| 29 | + using SysML2.NET.Core.POCO.Systems.Attributes; |
| 30 | + using SysML2.NET.Extensions; |
28 | 31 |
|
29 | 32 | [TestFixture] |
30 | 33 | public class AttributeUsageExtensionsTestFixture |
31 | 34 | { |
32 | 35 | [Test] |
33 | | - public void ComputeAttributeDefinition_ThrowsNotSupportedException() |
| 36 | + public void VerifyComputeAttributeDefinition() |
34 | 37 | { |
35 | | - Assert.That(() => ((IAttributeUsage)null).ComputeAttributeDefinition(), Throws.TypeOf<NotSupportedException>()); |
| 38 | + Assert.That(() => ((IAttributeUsage)null).ComputeAttributeDefinition(), Throws.TypeOf<ArgumentNullException>()); |
| 39 | + |
| 40 | + var emptySubject = new AttributeUsage(); |
| 41 | + |
| 42 | + Assert.That(emptySubject.ComputeAttributeDefinition(), Has.Count.EqualTo(0)); |
| 43 | + |
| 44 | + var subject = new AttributeUsage(); |
| 45 | + var attributeDefinition = new AttributeDefinition(); |
| 46 | + var bareClassifier = new Classifier(); |
| 47 | + |
| 48 | + subject.AssignOwnership(new FeatureTyping { Type = attributeDefinition }); |
| 49 | + subject.AssignOwnership(new FeatureTyping { Type = bareClassifier }); |
| 50 | + |
| 51 | + // Only the IDataType (AttributeDefinition) is returned; bare Classifier is excluded. |
| 52 | + Assert.That(subject.ComputeAttributeDefinition(), Is.EquivalentTo(new[] { attributeDefinition })); |
36 | 53 | } |
37 | | - |
| 54 | + |
38 | 55 | [Test] |
39 | | - public void ComputeIsReference_ThrowsNotSupportedException() |
| 56 | + public void VerifyComputeIsReference() |
40 | 57 | { |
41 | | - Assert.That(() => ((IAttributeUsage)null).ComputeIsReference(), Throws.TypeOf<NotSupportedException>()); |
| 58 | + Assert.That(() => ((IAttributeUsage)null).ComputeIsReference(), Throws.TypeOf<ArgumentNullException>()); |
| 59 | + |
| 60 | + var emptySubject = new AttributeUsage(); |
| 61 | + |
| 62 | + Assert.That(emptySubject.ComputeIsReference(), Is.True); |
| 63 | + |
| 64 | + var populatedSubject = new AttributeUsage(); |
| 65 | + var attributeDefinition = new AttributeDefinition(); |
| 66 | + populatedSubject.AssignOwnership(new FeatureTyping { Type = attributeDefinition }); |
| 67 | + |
| 68 | + // Always true regardless of subject state — AttributeUsages are always referential. |
| 69 | + Assert.That(populatedSubject.ComputeIsReference(), Is.True); |
42 | 70 | } |
43 | 71 | } |
44 | 72 | } |
0 commit comments