-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Implement] DirectedRelationshipExtensions - Source and Target for Ge…
…neralization [Implement] RelationshipExtensions - QueryRelatedElement for Generalization
- Loading branch information
1 parent
51e479e
commit d6817f5
Showing
5 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
uml4net.Tests/Extend/DirectedRelationshipExtensionsTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// <copyright file="DirectedRelationshipExtensionsTestFixture.cs" company="Starion Group S.A."> | ||
// | ||
// Copyright 2019-2024 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. | ||
// | ||
// </copyright> | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
namespace uml4net.Tests.Extend | ||
{ | ||
using NUnit.Framework; | ||
|
||
using uml4net.Classification; | ||
using uml4net.StructuredClassifiers; | ||
|
||
[TestFixture] | ||
public class DirectedRelationshipExtensionsTestFixture | ||
{ | ||
[Test] | ||
public void Verify_that_when_Generalization_Source_and_Target_return_expected_result() | ||
{ | ||
var animal = new Class { Name = "Animal" }; | ||
var mammal = new Class { Name = "Mammal" }; | ||
var cat = new Class { Name = "Cat" }; | ||
|
||
var animal_is_generalization_of_mammal = new Generalization(); | ||
animal_is_generalization_of_mammal.General = animal; | ||
animal_is_generalization_of_mammal.Specific = mammal; | ||
|
||
var mammal_is_generalization_of_cat = new Generalization(); | ||
mammal_is_generalization_of_cat.General = mammal; | ||
mammal_is_generalization_of_cat.Specific = cat; | ||
|
||
cat.Generalization.Add(mammal_is_generalization_of_cat); | ||
animal.Generalization.Add(animal_is_generalization_of_mammal); | ||
|
||
Assert.That(animal_is_generalization_of_mammal.Source, Is.EquivalentTo([mammal] )); | ||
Assert.That(animal_is_generalization_of_mammal.Target, Is.EquivalentTo([animal])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// <copyright file="RelationshipExtensionsTestFixture.cs" company="Starion Group S.A."> | ||
// | ||
// Copyright 2019-2024 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. | ||
// | ||
// </copyright> | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
namespace uml4net.Tests.Extend | ||
{ | ||
using NUnit.Framework; | ||
|
||
using uml4net.Classification; | ||
using uml4net.StructuredClassifiers; | ||
|
||
[TestFixture] | ||
public class RelationshipExtensionsTestFixture | ||
{ | ||
[Test] | ||
public void Verify_that_when_Generalization_QueryRelatedElement_return_expected_result() | ||
{ | ||
var animal = new Class { Name = "Animal" }; | ||
var mammal = new Class { Name = "Mammal" }; | ||
var cat = new Class { Name = "Cat" }; | ||
|
||
var animal_is_generalization_of_mammal = new Generalization(); | ||
animal_is_generalization_of_mammal.General = animal; | ||
animal_is_generalization_of_mammal.Specific = mammal; | ||
|
||
var mammal_is_generalization_of_cat = new Generalization(); | ||
mammal_is_generalization_of_cat.General = mammal; | ||
mammal_is_generalization_of_cat.Specific = cat; | ||
|
||
cat.Generalization.Add(mammal_is_generalization_of_cat); | ||
animal.Generalization.Add(animal_is_generalization_of_mammal); | ||
|
||
Assert.That(animal_is_generalization_of_mammal.RelatedElement, Is.EquivalentTo([animal, mammal])); | ||
Assert.That(mammal_is_generalization_of_cat.RelatedElement, Is.EquivalentTo([mammal, cat])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters