|
1 | 1 | // ------------------------------------------------------------------------------------------------- |
2 | 2 | // <copyright file="UnioningExtensionsTestFixture.cs" company="Starion Group S.A."> |
3 | 3 | // |
4 | | -// Copyright 2022-2026 Starion Group S.A. |
| 4 | +// Copyright (C) 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. |
|
21 | 21 | namespace SysML2.NET.Tests.Extend |
22 | 22 | { |
23 | 23 | using System; |
24 | | - |
| 24 | + |
25 | 25 | using NUnit.Framework; |
26 | | - |
| 26 | + |
27 | 27 | 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; |
28 | 33 |
|
29 | 34 | [TestFixture] |
30 | 35 | public class UnioningExtensionsTestFixture |
31 | 36 | { |
32 | 37 | [Test] |
33 | | - public void ComputeTypeUnioned_ThrowsNotSupportedException() |
| 38 | + public void VerifyComputeTypeUnioned() |
34 | 39 | { |
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>()); |
36 | 63 | } |
37 | 64 | } |
38 | 65 | } |
0 commit comments