Ejemplo n.º 1
0
        public void MoreComplexTest()
        {
            GoatAssociationEndModel AssociationEnd = new GoatAssociationEndModel
            {
                Role         = nameof(AssociationEnd),
                Aggregation  = AggregationType.None,
                Multiplicity = "10",
                Union        = false,
                Derived      = false
            };

            Assert.IsTrue(AssociationEnd.Role == nameof(AssociationEnd) && AssociationEnd.Aggregation == AggregationType.None &&
                          AssociationEnd.Multiplicity == "10" && !AssociationEnd.Union && !AssociationEnd.Derived, "Test 1");

            AssociationEnd.Union = true;
            Assert.IsTrue(AssociationEnd.Role == nameof(AssociationEnd) && AssociationEnd.Aggregation == AggregationType.None &&
                          AssociationEnd.Multiplicity == "10" && AssociationEnd.Union && AssociationEnd.Derived, "Test 2");

            AssociationEnd.Aggregation = AggregationType.Composite;
            Assert.IsTrue(AssociationEnd.Role == nameof(AssociationEnd) && AssociationEnd.Aggregation == AggregationType.Composite &&
                          AssociationEnd.Multiplicity == GoatAssociationEndModel.MultiplicityWhenCompostite &&
                          AssociationEnd.Union && AssociationEnd.Derived, "Test 3");

            AssociationEnd.Multiplicity = "10..15";
            Assert.IsTrue(AssociationEnd.Role == nameof(AssociationEnd) && AssociationEnd.Aggregation == AggregationType.None &&
                          AssociationEnd.Multiplicity == "10..15" && AssociationEnd.Union && AssociationEnd.Derived, "Test 4");
        }
Ejemplo n.º 2
0
        public void UnionMeansDerived()
        {
            GoatAssociationEndModel AssociationEnd = new GoatAssociationEndModel
            {
                Union = true
            };

            Assert.IsTrue(AssociationEnd.Union, "Union is not true.");
            Assert.IsTrue(AssociationEnd.Derived, "Although Union is true, Derived is false.");
        }
Ejemplo n.º 3
0
        public void ChangeDerivedToFalseMeansNoUnion()
        {
            GoatAssociationEndModel AssociationEnd = new GoatAssociationEndModel
            {
                Union   = true,
                Derived = false
            };

            Assert.IsFalse(AssociationEnd.Derived, "Derived is not true.");
            Assert.IsFalse(AssociationEnd.Union, "Although Derived is false, Derived is false.");
        }
Ejemplo n.º 4
0
        public void NavigabilityChangeMeansPossibleOwnershipChange()
        {
            //it is not a UML rule but is reasonable
            GoatAssociationEndModel AssociationEnd = new GoatAssociationEndModel
            {
                IsOwnedByClassifier = true,
                Navigability        = NavigabilityType.NonNavigable
            };

            Assert.IsTrue(AssociationEnd.Navigability == NavigabilityType.NonNavigable, "AssociationEnd.Navigability != NavigabilityType.NonNavigable.");
            Assert.IsFalse(AssociationEnd.IsOwnedByClassifier, "Ownership failure.");
        }
Ejemplo n.º 5
0
        public void IsOwnedByClassifierDoesntMeanNonNavigable()
        {
            //it is not a UML rule but is reasonable
            GoatAssociationEndModel AssociationEnd = new GoatAssociationEndModel
            {
                Navigability        = NavigabilityType.NonNavigable,
                IsOwnedByClassifier = true
            };

            Assert.IsTrue(AssociationEnd.IsOwnedByClassifier, "IsOwnedByClassifier is not true.");
            Assert.IsTrue(AssociationEnd.Navigability != NavigabilityType.NonNavigable, "Navigability failure.");
        }
Ejemplo n.º 6
0
        public void MultiplicityChangeMeansCompositePossibleChange()
        {
            string s = "any random string.";
            GoatAssociationEndModel AssociationEnd = new GoatAssociationEndModel
            {
                Aggregation  = AggregationType.Composite,
                Multiplicity = s
            };

            Assert.IsTrue(AssociationEnd.Multiplicity == s, "Multiplicity wasn't changed.");
            Assert.IsFalse(AssociationEnd.Aggregation == AggregationType.Composite, "Aggregation is Composite!");
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Setter for Right and Left CustomMultiplicity
 /// </summary>
 /// <param name="CustomMultiplicity">target for a new value</param>
 /// <param name="NewValue">new value that will be assigned</param>
 /// <param name="GoatAssociationEnd">an instance of GoatAssociationEnd whose multiplicity will be changed</param>
 /// <param name="MultiplicityType">Right or Left multiplicity type that will be changed</param>
 /// <param name="ChangedPropertyName">Name of property that is changed</param>
 private void SetRightOrLeftCustomMultiplicity(ref string CustomMultiplicity,
                                               string NewValue,
                                               GoatAssociationEndModel GoatAssociationEnd,
                                               MultiplicityType MultiplicityType,
                                               string ChangedPropertyName)
 {
     if (CustomMultiplicity != NewValue)
     {
         CustomMultiplicity = NewValue;
         GoatAssociationEnd.Multiplicity = NewValue;
         MultiplicityType = MultiplicityType.Other;
         RaisePropertyChanged(ChangedPropertyName);
     }
 }
Ejemplo n.º 8
0
        public void CompositeMeansStrictMultiplicity()
        {
            GoatAssociationEndModel AssociationEnd = new GoatAssociationEndModel
            {
                Multiplicity = "any random string.",
                Aggregation  = AggregationType.Composite
            };

            Assert.IsTrue(AssociationEnd.Aggregation == AggregationType.Composite, "Aggregation is not Composite!");
            Assert.IsTrue(AssociationEnd.Multiplicity == GoatAssociationEndModel.MultiplicityWhenCompostite, "Multiplicity wasn't changed.");

            AssociationEnd.Aggregation  = AggregationType.None;
            AssociationEnd.Multiplicity = "";
            AssociationEnd.Aggregation  = AggregationType.Composite;
            Assert.IsTrue(AssociationEnd.Multiplicity == "", "Multiplicity has been changed.");
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Setter for LeftMultiplicityType and RightMultiplicityType
        /// </summary>
        /// <param name="LeftRightMultiplicityType">internal attribute for storing value of the Propertyu</param>
        /// <param name="NewValue">New value for the property/attribute</param>
        /// <param name="AssociationEnd">instance of AssociationEnd whose Multiplicity will be changed</param>
        /// <param name="NameOfProperty">name of the property that is going to be changed</param>
        private void SetLeftOrRightMultiplicityType(ref MultiplicityType LeftRightMultiplicityType, MultiplicityType NewValue, GoatAssociationEndModel AssociationEnd, string NameOfProperty)
        {
            if (LeftRightMultiplicityType != NewValue)
            {
                LeftRightMultiplicityType = NewValue;

                switch (NewValue)
                {
                case MultiplicityType.None:
                    AssociationEnd.Multiplicity = "";
                    break;

                case MultiplicityType.ZeroToOne:
                    AssociationEnd.Multiplicity = "0..1";
                    break;

                case MultiplicityType.ZeroToMany:
                    AssociationEnd.Multiplicity = "0..*";
                    break;

                case MultiplicityType.One:
                    AssociationEnd.Multiplicity = "1";
                    break;

                case MultiplicityType.OneToMany:
                    AssociationEnd.Multiplicity = "1..*";
                    break;

                case MultiplicityType.Many:
                    AssociationEnd.Multiplicity = "*";
                    break;

                case MultiplicityType.Other:
                    AssociationEnd.Multiplicity = _rightCustomMultiplicity;
                    break;

                default:
                    throw new NotImplementedException($"setter of {NameOfProperty}");
                }
                RaisePropertyChanged(NameOfProperty);
            }
        }
Ejemplo n.º 10
0
 private void AdjustRoleName(GoatAssociationEndModel GoatAssociationEnd)
 {
     GoatAssociationEnd.Role = GoatAssociationEnd.MemberEnd;
 }