Exemple #1
0
        public void Verify_that_When_Source_is_null_WriteXml_throws_exception()
        {
            var stream = new MemoryStream();
            var writer = XmlWriter.Create(stream, this.settings);

            var specRelationType = new SpecRelationType();

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

            Assert.That(
                () => specRelation.WriteXml(writer),
                Throws.Exception.TypeOf <SerializationException>()
                .With.Message.Contains("The Source of SpecRelation SpecRelationIdentifier:SpecRelationLongName may not be null"));
        }
        public override void ProcessElementStartNode(string name)
        {
            switch (name)
            {
            case specificationTypeNodeName:
                identifiableElementUnderConstruction = new SpecificationType();
                break;

            case specObjectTypeNodeName:
                identifiableElementUnderConstruction = new SpecObjectType();
                break;

            case specRelationTypeNodeName:
                identifiableElementUnderConstruction = new SpecRelationType();
                break;

            case relationGroupTypeNodeName:
                identifiableElementUnderConstruction = new RelationGroupType();
                break;

            default:
                throw new ParserFailureException(unexpectedElementNodeErrorText + name + "'.");
            }
        }
        public override void ProcessElementStartNode(string name)
        {
            switch (name)
            {
                case specificationTypeNodeName:
                    identifiableElementUnderConstruction = new SpecificationType();
                    break;

                case specObjectTypeNodeName:
                    identifiableElementUnderConstruction = new SpecObjectType();
                    break;

                case specRelationTypeNodeName:
                    identifiableElementUnderConstruction = new SpecRelationType();
                    break;

                case relationGroupTypeNodeName:
                    identifiableElementUnderConstruction = new RelationGroupType();
                    break;

                default:
                    throw new ParserFailureException(unexpectedElementNodeErrorText + name + "'.");
            }
        }
        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
            });
        }
Exemple #5
0
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.assembler = new Assembler(this.uri);

            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationSetup = this.iterationSetup
            };

            this.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);
            this.sitedir.Domain.Add(this.domain);
            this.model.Iteration.Add(this.iteration);

            this.person      = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Person = this.person
            };
            this.sitedir.Person.Add(this.person);
            this.modelsetup.Participant.Add(this.participant);

            this.pt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl.ParameterType.Add(this.pt);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) }
            });

            this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.assembler.Cache.TryAdd(new CacheKey(this.sitedir.Iid, null), new Lazy <Thing>(() => this.sitedir));
            this.reqIf      = new ReqIF();
            this.reqIf.Lang = "en";
            var corecontent = new ReqIFContent();

            this.reqIf.CoreContent.Add(corecontent);
            this.stringDatadef = new DatatypeDefinitionString();
            this.spectype      = new SpecRelationType();
            this.attribute     = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.spectype.SpecAttributes.Add(this.attribute);

            corecontent.DataTypes.Add(this.stringDatadef);

            this.dialog = new SpecRelationTypeMappingDialogViewModel(new List <SpecRelationType> {
                this.spectype
            }, null, new Dictionary <DatatypeDefinition, DatatypeDefinitionMap> {
                { this.stringDatadef, new DatatypeDefinitionMap(this.stringDatadef, this.pt, null) }
            }, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, "en");
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpecRelationTypeMap"/> class
 /// </summary>
 /// <param name="specType">The <see cref="SpecType"/></param>
 /// <param name="rules">The <see cref="ParameterizedCategoryRule"/> associated</param>
 /// <param name="categories">The <see cref="Category"/> associated</param>
 /// <param name="attributeDefMap">The <see cref="AttributeDefinitionMap"/>s for this <see cref="SpecType"/></param>
 /// <param name="binaryRelationshipRules">The <see cref="BinaryRelationshipRule"/> applied</param>
 public SpecRelationTypeMap(SpecRelationType specType, IEnumerable <ParameterizedCategoryRule> rules, IEnumerable <Category> categories, IEnumerable <AttributeDefinitionMap> attributeDefMap, IEnumerable <BinaryRelationshipRule> binaryRelationshipRules)
     : base(specType, rules, categories, attributeDefMap)
 {
     this.BinaryRelationshipRules = binaryRelationshipRules != null?binaryRelationshipRules.ToArray() : null;
 }
        /// <summary>
        /// create a <see cref="SpecRelationType"/> with attribute definitions
        /// </summary>
        private void CreateSpecRelationType()
        {
            var reqIfContent = this.reqIF.CoreContent.SingleOrDefault();

            var specRelationType = new SpecRelationType();

            specRelationType.LongName   = "Specification Relation Type";
            specRelationType.Identifier = "specificationrelation";
            specRelationType.LastChange = DateTime.Parse("2015-12-01");

            var attributeDefinitionBoolean = new AttributeDefinitionBoolean();

            attributeDefinitionBoolean.LongName   = "boolean attribute";
            attributeDefinitionBoolean.Identifier = "specificationrelation-boolean-attribute";
            attributeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01");
            attributeDefinitionBoolean.Type       = (DatatypeDefinitionBoolean)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionBoolean));
            specRelationType.SpecAttributes.Add(attributeDefinitionBoolean);

            var attributeDefinitionDate = new AttributeDefinitionDate();

            attributeDefinitionDate.LongName   = "date attribute";
            attributeDefinitionDate.Identifier = "specificationrelation-date-attribute";
            attributeDefinitionDate.LastChange = DateTime.Parse("2015-12-01");
            attributeDefinitionDate.Type       = (DatatypeDefinitionDate)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionDate));
            specRelationType.SpecAttributes.Add(attributeDefinitionDate);

            var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration();

            attributeDefinitionEnumeration.LongName   = "enumeration attribute";
            attributeDefinitionEnumeration.Identifier = "specificationrelation-enumeration-attribute";
            attributeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01");
            attributeDefinitionEnumeration.Type       = (DatatypeDefinitionEnumeration)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionEnumeration));
            specRelationType.SpecAttributes.Add(attributeDefinitionEnumeration);

            var attributeDefinitionInteger = new AttributeDefinitionInteger();

            attributeDefinitionInteger.LongName   = "integer attribute";
            attributeDefinitionInteger.Identifier = "specificationrelation-integer-attribute";
            attributeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01");
            attributeDefinitionInteger.Type       = (DatatypeDefinitionInteger)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionInteger));
            specRelationType.SpecAttributes.Add(attributeDefinitionInteger);

            var attributeDefinitionReal = new AttributeDefinitionReal();

            attributeDefinitionReal.LongName   = "real attribute";
            attributeDefinitionReal.Identifier = "specificationrelation-real-attribute";
            attributeDefinitionReal.LastChange = DateTime.Parse("2015-12-01");
            attributeDefinitionReal.Type       = (DatatypeDefinitionReal)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionReal));
            specRelationType.SpecAttributes.Add(attributeDefinitionReal);

            var attributeDefinitionString = new AttributeDefinitionString();

            attributeDefinitionString.LongName   = "string attribute";
            attributeDefinitionString.Identifier = "specificationrelation-string-attribute";
            attributeDefinitionString.LastChange = DateTime.Parse("2015-12-01");
            attributeDefinitionString.Type       = (DatatypeDefinitionString)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionString));
            specRelationType.SpecAttributes.Add(attributeDefinitionString);

            var attributeDefinitionXhtml = new AttributeDefinitionXHTML();

            attributeDefinitionXhtml.LongName   = "xhtml attribute";
            attributeDefinitionXhtml.Identifier = "specificationrelation-xhtml-attribute";
            attributeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01");
            attributeDefinitionXhtml.Type       = (DatatypeDefinitionXHTML)reqIfContent.DataTypes.SingleOrDefault(x => x.GetType() == typeof(DatatypeDefinitionXHTML));
            specRelationType.SpecAttributes.Add(attributeDefinitionXhtml);

            reqIfContent.SpecTypes.Add(specRelationType);
        }
Exemple #8
0
        private void SetupData()
        {
            var datatypeDefinition0 = new DatatypeDefinitionString()
            {
                Identifier = this.reqIf.CoreContent?.DataTypes[0].Identifier
            };
            var datatypeDefinition1 = new DatatypeDefinitionString()
            {
                Identifier = this.reqIf.CoreContent?.DataTypes[1].Identifier
            };

            var specObjectType0 = new SpecObjectType()
            {
                Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecObjectType>().ToList()[0].Identifier
            };
            var specObjectType1 = new SpecObjectType()
            {
                Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecObjectType>().ToList()[1].Identifier
            };

            var specRelationType0 = new SpecRelationType()
            {
                Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecRelationType>().ToList()[0].Identifier
            };

            this.rule0 = new ParameterizedCategoryRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));
            this.rule1 = new ParameterizedCategoryRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));
            this.session.Assembler.Cache.TryAdd(new CacheKey(this.rule0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.rule0));
            this.session.Assembler.Cache.TryAdd(new CacheKey(this.rule1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.rule1));

            this.category0 = new Category(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));
            this.category1 = new Category(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));
            this.session.Assembler.Cache.TryAdd(new CacheKey(this.category0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.category0));
            this.session.Assembler.Cache.TryAdd(new CacheKey(this.category1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.category1));

            var specObjectTypeMap0 = new SpecObjectTypeMap(specObjectType0,
                                                           new[] { this.rule0, this.rule1 },
                                                           new[] { this.category0, this.category1 },
                                                           new[]
            {
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier
                }, AttributeDefinitionMapKind.NAME),
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier
                }, AttributeDefinitionMapKind.SHORTNAME)
            },
                                                           true);

            var specObjectTypeMap1 = new SpecObjectTypeMap(specObjectType1,
                                                           new[] { this.rule0, this.rule1 },
                                                           new[] { this.category0, this.category1 },
                                                           new[]
            {
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier
                }, AttributeDefinitionMapKind.NAME),
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier
                }, AttributeDefinitionMapKind.SHORTNAME)
            },
                                                           true);

            this.binaryRelationshipRule0 = new BinaryRelationshipRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));
            this.binaryRelationshipRule1 = new BinaryRelationshipRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));

            this.session.Assembler.Cache.TryAdd(new CacheKey(this.binaryRelationshipRule0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.binaryRelationshipRule0));
            this.session.Assembler.Cache.TryAdd(new CacheKey(this.binaryRelationshipRule1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.binaryRelationshipRule1));

            var specRelationTypeMap0 = new SpecRelationTypeMap(specRelationType0,
                                                               new[] { this.rule0, this.rule1 },
                                                               new[] { this.category0, this.category1 },
                                                               new[]
            {
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier
                }, AttributeDefinitionMapKind.NAME),
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier
                }, AttributeDefinitionMapKind.SHORTNAME)
            },
                                                               new[] { this.binaryRelationshipRule0, this.binaryRelationshipRule1 });

            var relationGroupType0 = new RelationGroupType()
            {
                Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecRelationType>().ToList()[0].Identifier
            };

            var relationGroupTypeMap0 = new RelationGroupTypeMap(relationGroupType0,
                                                                 new[] { this.rule0, this.rule1 },
                                                                 new[] { this.category0, this.category1 },
                                                                 new[]
            {
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier
                }, AttributeDefinitionMapKind.NAME),
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier
                }, AttributeDefinitionMapKind.SHORTNAME)
            },
                                                                 new[] { this.binaryRelationshipRule0, this.binaryRelationshipRule1 });

            var specificationType0 = this.reqIf.CoreContent?.SpecTypes.OfType <SpecificationType>().First();

            var specificationTypeMap0 = new SpecTypeMap(specificationType0,
                                                        new[] { this.rule0, this.rule1 },
                                                        new[] { this.category0, this.category1 },
                                                        new[]
            {
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier
                }, AttributeDefinitionMapKind.NAME),
                new AttributeDefinitionMap(new AttributeDefinitionString()
                {
                    Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier
                }, AttributeDefinitionMapKind.SHORTNAME)
            });

            this.parameterType0 = new TextParameterType(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));
            this.parameterType1 = new TextParameterType(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri));
            this.session.Assembler.Cache.TryAdd(new CacheKey(this.parameterType0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameterType0));
            this.session.Assembler.Cache.TryAdd(new CacheKey(this.parameterType1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameterType1));

            this.mappingConfiguration = new ImportMappingConfiguration()
            {
                Name                  = "TestName",
                Description           = "TestDescription",
                DatatypeDefinitionMap =
                {
                    { datatypeDefinition0, new DatatypeDefinitionMap(datatypeDefinition0, this.parameterType0, new Dictionary <EnumValue, EnumerationValueDefinition>()
                        {
                            { new EnumValue(),     new EnumerationValueDefinition() }
                        }) },
                    { datatypeDefinition1, new DatatypeDefinitionMap(datatypeDefinition1, this.parameterType1, new Dictionary <EnumValue, EnumerationValueDefinition>()
                        {
                            { new EnumValue(),     new EnumerationValueDefinition() }
                        }) }
                },
                SpecObjectTypeMap =
                {
                    { specObjectType0, specObjectTypeMap0 },
                    { specObjectType1, specObjectTypeMap1 }
                },
                SpecRelationTypeMap =
                {
                    { specRelationType0, specRelationTypeMap0 }
                },
                RelationGroupTypeMap =
                {
                    { relationGroupType0, relationGroupTypeMap0 }
                },
                SpecificationTypeMap =
                {
                    { specificationType0, specificationTypeMap0 }
                }
            };

            this.settings = new RequirementsModuleSettings()
            {
                SavedConfigurations = { this.mappingConfiguration }
            };
        }