Пример #1
0
        public void VerifyThatExceptionIsThrownWhenInvalidTypeIsSet()
        {
            var relationGroupType         = new RelationGroupType();
            var specRelation              = new SpecRelation();
            var specElementWithAttributes = (SpecElementWithAttributes)specRelation;

            Assert.Throws <ArgumentException>(() => specElementWithAttributes.SpecType = relationGroupType);
        }
Пример #2
0
        public void Verify_that_When_Type_is_null_WriteXml_throws_exception()
        {
            var stream = new MemoryStream();
            var writer = XmlWriter.Create(stream, this.settings);

            var specRelation = new SpecRelation
            {
                Identifier = "SpecRelationIdentifier",
                LongName   = "SpecRelationLongName"
            };

            Assert.That(
                () => specRelation.WriteXml(writer),
                Throws.Exception.TypeOf <SerializationException>()
                .With.Message.Contains("The Type of SpecRelation SpecRelationIdentifier:SpecRelationLongName may not be null"));
        }
Пример #3
0
        public void VerifyThatTheSpecTypeCanBeSetOrGet()
        {
            var specRelationType = new SpecRelationType();

            var specRelation = new SpecRelation();

            specRelation.Type = specRelationType;

            var specElementWithAttributes = (SpecElementWithAttributes)specRelation;

            Assert.AreEqual(specRelationType, specElementWithAttributes.SpecType);

            var relationType = new SpecRelationType();

            specElementWithAttributes.SpecType = relationType;

            Assert.AreEqual(relationType, specRelation.SpecType);
        }
        /// <summary>
        /// create a <see cref="SpecRelation"/>s
        /// </summary>
        private void CreateSpecRelations()
        {
            var reqIfContent = this.reqIF.CoreContent.SingleOrDefault();

            var specRelationType = (SpecRelationType)reqIfContent.SpecTypes.SingleOrDefault(x => x.GetType() == typeof(SpecRelationType));
            var source           = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_1_id);
            var target           = reqIfContent.SpecObjects.SingleOrDefault(x => x.Identifier == this.specobject_2_id);

            var specRelation = new SpecRelation();

            specRelation.Identifier = string.Format("{0}-{1}", source.Identifier, target.Identifier);
            specRelation.LastChange = DateTime.Parse("2015-12-01");
            specRelation.LongName   = "A relationship between spec objects";
            specRelation.Type       = specRelationType;
            specRelation.Source     = source;
            specRelation.Target     = target;
            this.CreateValuesForSpecElementWithAttributes(specRelation, specRelationType);

            reqIfContent.SpecRelations.Add(specRelation);
        }
Пример #5
0
        /// <summary>
        /// Creates a <see cref="BinaryRelationship"/> from a <see cref="SpecRelation"/>
        /// </summary>
        /// <param name="relation">The <see cref="SpecRelat"/></param>
        /// <returns></returns>
        private BinaryRelationship CreateBinaryRelationship(SpecRelation relation)
        {
            var type = this.typeMap[relation.Type];

            var relationship = new BinaryRelationship
            {
                Owner = this.Owner
            };

            Requirement source;
            Requirement target;

            if (!this.specObjectMap.TryGetValue(relation.Source, out source) || !this.specObjectMap.TryGetValue(relation.Target, out target))
            {
                throw new InvalidOperationException("The source or target cannot be null. Verify that the ReqIF input is valid.");
            }

            relationship.Source = source;
            relationship.Target = target;

            relationship.Category.AddRange(type.Categories);
            foreach (var value in relation.Values)
            {
                var attributeMap = type.AttributeDefinitionMap.SingleOrDefault(x => x.AttributeDefinition == value.AttributeDefinition);
                if (attributeMap == null || attributeMap.MapKind == AttributeDefinitionMapKind.NONE)
                {
                    continue;
                }

                switch (attributeMap.MapKind)
                {
                case AttributeDefinitionMapKind.PARAMETER_VALUE:
                    this.SetParameterValue(relationship, value);
                    break;
                }
            }

            this.specRelationMap.Add(relation, relationship);
            return(relationship);
        }
        private void SetupReqIf()
        {
            this.reqIf             = new ReqIF();
            this.reqIf.Lang        = "en";
            this.corecontent       = new ReqIFContent();
            this.reqIf.CoreContent = this.corecontent;
            this.stringDatadef     = new DatatypeDefinitionString();
            this.specificationtype = new SpecificationType();
            this.specobjecttype    = new SpecObjectType();
            this.specrelationtype  = new SpecRelationType();
            this.relationgrouptype = new RelationGroupType();

            this.specAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.reqAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };
            this.specRelationAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };
            this.relationgroupAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.specificationtype.SpecAttributes.Add(this.specAttribute);
            this.specobjecttype.SpecAttributes.Add(this.reqAttribute);
            this.specrelationtype.SpecAttributes.Add(this.specRelationAttribute);
            this.relationgrouptype.SpecAttributes.Add(this.relationgroupAttribute);

            this.specification1 = new Specification()
            {
                Type = this.specificationtype
            };
            this.specification2 = new Specification()
            {
                Type = this.specificationtype
            };

            this.specobject1 = new SpecObject()
            {
                Type = this.specobjecttype
            };
            this.specobject2 = new SpecObject()
            {
                Type = this.specobjecttype
            };

            this.specrelation = new SpecRelation()
            {
                Type = this.specrelationtype, Source = this.specobject1, Target = this.specobject2
            };
            this.relationgroup = new RelationGroup()
            {
                Type = this.relationgrouptype, SourceSpecification = this.specification1, TargetSpecification = this.specification2
            };

            this.specValue1 = new AttributeValueString()
            {
                AttributeDefinition = this.specAttribute, TheValue = "spec1"
            };
            this.specValue2 = new AttributeValueString()
            {
                AttributeDefinition = this.specAttribute, TheValue = "spec2"
            };
            this.objectValue1 = new AttributeValueString()
            {
                AttributeDefinition = this.reqAttribute, TheValue = "req1"
            };
            this.objectValue2 = new AttributeValueString()
            {
                AttributeDefinition = this.reqAttribute, TheValue = "req2"
            };
            this.relationgroupValue = new AttributeValueString()
            {
                AttributeDefinition = this.relationgroupAttribute, TheValue = "group"
            };
            this.specrelationValue = new AttributeValueString()
            {
                AttributeDefinition = this.specRelationAttribute, TheValue = "specrelation"
            };

            this.specification1.Values.Add(this.specValue1);
            this.specification2.Values.Add(this.specValue2);
            this.specobject1.Values.Add(this.objectValue1);
            this.specobject2.Values.Add(this.objectValue2);
            this.specrelation.Values.Add(this.specrelationValue);
            this.relationgroup.Values.Add(this.relationgroupValue);

            this.corecontent.DataTypes.Add(this.stringDatadef);
            this.corecontent.SpecTypes.AddRange(new SpecType[] { this.specobjecttype, this.specificationtype, this.specrelationtype, this.relationgrouptype });
            this.corecontent.SpecObjects.AddRange(new SpecObject[] { this.specobject1, this.specobject2 });
            this.corecontent.Specifications.AddRange(new Specification[] { this.specification1, this.specification2 });
            this.corecontent.SpecRelations.Add(this.specrelation);
            this.corecontent.SpecRelationGroups.Add(this.relationgroup);

            this.specification1.Children.Add(new SpecHierarchy()
            {
                Object = this.specobject1
            });
            this.specification2.Children.Add(new SpecHierarchy()
            {
                Object = this.specobject2
            });
        }