Beispiel #1
0
        public void VerifyThatThingFactoryWorks()
        {
            var datatypeMap  = new Dictionary <DatatypeDefinition, DatatypeDefinitionMap>();
            var datatypedef1 = new DatatypeDefinitionMap(this.stringDatadef, this.pt, null);

            datatypeMap.Add(this.stringDatadef, datatypedef1);

            var spectypeMap      = new Dictionary <SpecType, SpecTypeMap>();
            var specificationMap = new SpecTypeMap(this.specificationtype, null, new [] { this.specCategory }, new [] { new AttributeDefinitionMap(this.specAttribute, AttributeDefinitionMapKind.NAME) });
            var requirementMap   = new SpecObjectTypeMap(this.specobjecttype, null, new [] { this.reqCateory }, new[] { new AttributeDefinitionMap(this.reqAttribute, AttributeDefinitionMapKind.FIRST_DEFINITION) }, true);
            var specRelationMap  = new SpecRelationTypeMap(this.specrelationtype, new [] { this.parameterRule }, new [] { this.specRelationCategory }, new[] { new AttributeDefinitionMap(this.specRelationAttribute, AttributeDefinitionMapKind.PARAMETER_VALUE) }, new [] { this.reqRule });
            var relationGroupMap = new RelationGroupTypeMap(this.relationgrouptype, null, new [] { this.relationGroupCategory }, new[] { new AttributeDefinitionMap(this.relationgroupAttribute, AttributeDefinitionMapKind.NONE) }, new [] { this.specRule });

            spectypeMap.Add(this.specificationtype, specificationMap);
            spectypeMap.Add(this.specobjecttype, requirementMap);
            spectypeMap.Add(this.specrelationtype, specRelationMap);
            spectypeMap.Add(this.relationgrouptype, relationGroupMap);

            var factory = new ThingFactory(this.iteration, datatypeMap, spectypeMap, this.domain, this.reqIf.Lang);

            factory.ComputeRequirementThings(this.reqIf);

            Assert.AreEqual(1, factory.RelationGroupMap.Count);
            Assert.AreEqual(1, factory.SpecRelationMap.Count);
            Assert.AreEqual(2, factory.SpecificationMap.Count);
            Assert.IsTrue(factory.SpecificationMap.All(x => x.Value.Requirement.Count == 1));


            var reqSpec1 = factory.SpecificationMap[this.specification1];
            var reqSpec2 = factory.SpecificationMap[this.specification2];
            var req1     = reqSpec1.Requirement.Single();
            var req2     = reqSpec2.Requirement.Single();

            var specificationRelationship = factory.RelationGroupMap.Single().Value;
            var reqRelatinoship           = factory.SpecRelationMap.Single().Value;

            Assert.AreSame(specificationRelationship.Source, reqSpec1);
            Assert.AreSame(specificationRelationship.Target, reqSpec2);
            Assert.AreSame(reqRelatinoship.Source, req1);
            Assert.AreSame(reqRelatinoship.Target, req2);

            Assert.IsNotEmpty(req1.Definition);
            Assert.IsNotEmpty(req2.Definition);

            Assert.AreEqual(reqSpec1.Name, this.specValue1.TheValue);
            Assert.AreEqual(reqSpec2.Name, this.specValue2.TheValue);

            var parameterValue = reqRelatinoship.ParameterValue.Single();

            Assert.AreEqual(parameterValue.Value[0], this.specrelationValue.TheValue);

            //todo to complete
        }
Beispiel #2
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 }
            };
        }