/// <summary> /// Returns the <see cref="DatatypeDefinitionString"/> representation of a text <see cref="ParameterType"/> /// </summary> /// <param name="definedThing">The <see cref="DefinedThing"/> the parameter type</param> /// <returns>The <see cref="DatatypeDefinitionString"/></returns> private DatatypeDefinitionString ToReqIfDatatypeDefinitionString(DefinedThing definedThing) { var datatype = new DatatypeDefinitionString(); this.SetIdentifiableProperties(datatype, definedThing); return(datatype); }
public void Verify_that_QueryDatatypeName_returns_expected_results() { var datatypeDefinitionBoolean = new DatatypeDefinitionBoolean(); Assert.That(datatypeDefinitionBoolean.QueryDatatypeName(), Is.EqualTo("Boolean")); var datatypeDefinitionDate = new DatatypeDefinitionDate(); Assert.That(datatypeDefinitionDate.QueryDatatypeName(), Is.EqualTo("Date")); var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration(); Assert.That(datatypeDefinitionEnumeration.QueryDatatypeName(), Is.EqualTo("Enumeration")); var datatypeDefinitionInteger = new DatatypeDefinitionInteger(); Assert.That(datatypeDefinitionInteger.QueryDatatypeName(), Is.EqualTo("Integer")); var datatypeDefinitionReal = new DatatypeDefinitionReal(); Assert.That(datatypeDefinitionReal.QueryDatatypeName(), Is.EqualTo("Real")); var datatypeDefinitionString = new DatatypeDefinitionString(); Assert.That(datatypeDefinitionString.QueryDatatypeName(), Is.EqualTo("String")); var datatypeDefinitionXhtml = new DatatypeDefinitionXHTML(); Assert.That(datatypeDefinitionXhtml.QueryDatatypeName(), Is.EqualTo("XHTML")); }
public void Verify_That_Exception_Is_Raised_When_Invalid_AttributeDefinition_Is_Set() { var datatypeDefinitionString = new DatatypeDefinitionString(); var attributeDefinitionInteger = new AttributeDefinitionInteger(); var attributeDefinition = (AttributeDefinition)attributeDefinitionInteger; Assert.Throws <ArgumentException>(() => attributeDefinition.DatatypeDefinition = datatypeDefinitionString); }
public void VerifytThatExceptionIsRaisedWhenInvalidAttributeDefinitionIsSet() { var datatypeDefinitionString = new DatatypeDefinitionString(); var attributeDefinitionDate = new AttributeDefinitionDate(); var attributeDefinition = (AttributeDefinition)attributeDefinitionDate; Assert.Throws <ArgumentException>(() => attributeDefinition.DatatypeDefinition = datatypeDefinitionString); }
public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get() { var datatypeDefinitionString = new DatatypeDefinitionString(); var attributeDefinitionString = new AttributeDefinitionString(); attributeDefinitionString.Type = datatypeDefinitionString; var attributeDefinition = (AttributeDefinition)attributeDefinitionString; Assert.AreEqual(datatypeDefinitionString, attributeDefinition.DatatypeDefinition); attributeDefinition.DatatypeDefinition = datatypeDefinitionString; Assert.AreEqual(datatypeDefinitionString, attributeDefinition.DatatypeDefinition); }
public void VerifyThatTheAttributeDefinitionCanBeSetOrGet() { var datatypeDefinitionString = new DatatypeDefinitionString(); var attributeDefinitionString = new AttributeDefinitionString(); attributeDefinitionString.Type = datatypeDefinitionString; var attributeDefinition = (AttributeDefinition)attributeDefinitionString; Assert.AreEqual(datatypeDefinitionString, attributeDefinition.DatatypeDefinition); attributeDefinition.DatatypeDefinition = datatypeDefinitionString; Assert.AreEqual(datatypeDefinitionString, attributeDefinition.DatatypeDefinition); }
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 RelationGroupType(); this.attribute = new AttributeDefinitionString() { DatatypeDefinition = this.stringDatadef }; this.spectype.SpecAttributes.Add(this.attribute); corecontent.DataTypes.Add(this.stringDatadef); this.dialog = new RelationGroupTypeMappingDialogViewModel(new List <RelationGroupType> { 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); }
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 }); }
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.reqIf = new ReqIF(); this.reqIf.Lang = "en"; var corecontent = new ReqIFContent(); this.reqIf.CoreContent = corecontent; this.stringDatadef = new DatatypeDefinitionString(); this.boolDatadef = new DatatypeDefinitionBoolean(); this.intDatadef = new DatatypeDefinitionInteger(); this.realDatadef = new DatatypeDefinitionReal(); this.enumDatadef = new DatatypeDefinitionEnumeration(); this.enumDatadef.SpecifiedValues.Add(new EnumValue { Properties = new EmbeddedValue { Key = 1, OtherContent = "enum1" } }); this.dateDatadef = new DatatypeDefinitionDate(); corecontent.DataTypes.Add(this.stringDatadef); corecontent.DataTypes.Add(this.boolDatadef); corecontent.DataTypes.Add(this.dateDatadef); corecontent.DataTypes.Add(this.enumDatadef); corecontent.DataTypes.Add(this.intDatadef); corecontent.DataTypes.Add(this.realDatadef); this.dialog = new ParameterTypeMappingDialogViewModel(this.reqIf.Lang, corecontent.DataTypes, null, this.iteration, this.session.Object, this.thingDialogNavigationService.Object); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir); }
/// <summary> /// create all the different <see cref="DatatypeDefinition"/>s /// </summary> private void CreateDataTypes() { var reqIfContent = this.reqIF.CoreContent.SingleOrDefault(); var datatypeDefinitionBoolean = new DatatypeDefinitionBoolean(); datatypeDefinitionBoolean.Description = "boolean data type definition"; datatypeDefinitionBoolean.Identifier = "boolean"; datatypeDefinitionBoolean.LastChange = DateTime.Parse("2015-12-01"); datatypeDefinitionBoolean.LongName = "a boolean"; reqIfContent.DataTypes.Add(datatypeDefinitionBoolean); var datatypeDefinitionDate = new DatatypeDefinitionDate(); datatypeDefinitionDate.Description = "date data type definition"; datatypeDefinitionDate.Identifier = "DateTime"; datatypeDefinitionDate.LastChange = DateTime.Parse("2015-12-01"); datatypeDefinitionDate.LongName = "a date"; reqIfContent.DataTypes.Add(datatypeDefinitionDate); var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration(); datatypeDefinitionEnumeration.Description = "enum value type definition"; datatypeDefinitionEnumeration.Identifier = this.enumdatatype_id; datatypeDefinitionEnumeration.LastChange = DateTime.Parse("2015-12-01"); datatypeDefinitionEnumeration.LongName = "an enumeration"; var enumValuelow = new EnumValue(); enumValuelow.Identifier = this.enum_value_low_id; enumValuelow.LastChange = DateTime.Parse("2015-12-01"); enumValuelow.LongName = "low"; var embeddedValueLow = new EmbeddedValue(); embeddedValueLow.Key = 1; embeddedValueLow.OtherContent = "foo"; enumValuelow.Properties = embeddedValueLow; var enumValuemedium = new EnumValue(); enumValuemedium.Identifier = this.enum_value_medium_id; enumValuemedium.LastChange = DateTime.Parse("2015-12-01"); enumValuemedium.LongName = "medium"; var embeddedValueMedium = new EmbeddedValue(); embeddedValueMedium.Key = 2; embeddedValueMedium.OtherContent = "bar"; enumValuemedium.Properties = embeddedValueMedium; datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuelow); datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuemedium); reqIfContent.DataTypes.Add(datatypeDefinitionEnumeration); var datatypeDefinitionInteger = new DatatypeDefinitionInteger(); datatypeDefinitionInteger.Description = "integer data type definition"; datatypeDefinitionInteger.Identifier = "integer"; datatypeDefinitionInteger.LastChange = DateTime.Parse("2015-12-01"); datatypeDefinitionInteger.LongName = "an integer"; datatypeDefinitionInteger.Min = 2; datatypeDefinitionInteger.Max = 6; reqIfContent.DataTypes.Add(datatypeDefinitionInteger); var datatypeDefinitionReal = new DatatypeDefinitionReal(); datatypeDefinitionReal.Description = "real data type definition"; datatypeDefinitionReal.Identifier = "real"; datatypeDefinitionReal.LastChange = DateTime.Parse("2015-12-01"); datatypeDefinitionReal.LongName = "a real"; datatypeDefinitionReal.Accuracy = 5; datatypeDefinitionReal.Min = 1; datatypeDefinitionReal.Max = 5; reqIfContent.DataTypes.Add(datatypeDefinitionReal); var datatypeDefinitionString = new DatatypeDefinitionString(); datatypeDefinitionString.Description = "string data type definition"; datatypeDefinitionString.Identifier = "string"; datatypeDefinitionString.LastChange = DateTime.Parse("2015-12-01"); datatypeDefinitionString.MaxLength = 32000; datatypeDefinitionString.LongName = "a string"; reqIfContent.DataTypes.Add(datatypeDefinitionString); var datatypeDefinitionXhtml = new DatatypeDefinitionXHTML(); datatypeDefinitionXhtml.Description = "string data type definition"; datatypeDefinitionXhtml.Identifier = "xhtml"; datatypeDefinitionXhtml.LastChange = DateTime.Parse("2015-12-01"); datatypeDefinitionXhtml.LongName = "a string"; reqIfContent.DataTypes.Add(datatypeDefinitionXhtml); }
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 } }; }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.dialogNavigationService = new Mock <IDialogNavigationService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.permissionService = new Mock <IPermissionService>(); this.path = Path.Combine(TestContext.CurrentContext.TestDirectory, "ReqIf", "testreq.reqif"); this.fileDialogService = new Mock <IOpenSaveFileDialogService>(); this.fileDialogService.Setup(x => x.GetOpenFileDialog(true, true, false, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), 1)).Returns(new string[] { this.path }); this.reqIf = new ReqIF { Lang = "en" }; this.reqIf.TheHeader = new ReqIFHeader() { Identifier = Guid.NewGuid().ToString() }; var corecontent = new ReqIFContent(); this.reqIf.CoreContent = corecontent; this.stringDatadef = new DatatypeDefinitionString(); this.spectype = new SpecificationType(); this.attribute = new AttributeDefinitionString() { DatatypeDefinition = this.stringDatadef }; this.spectype.SpecAttributes.Add(this.attribute); corecontent.DataTypes.Add(this.stringDatadef); this.settings = new RequirementsModuleSettings() { SavedConfigurations = { new ImportMappingConfiguration() { ReqIfId = this.reqIf.TheHeader.Identifier, Name = "Test" } } }; this.pluginSettingService = new Mock <IPluginSettingsService>(); this.pluginSettingService.Setup(x => x.Read <RequirementsModuleSettings>(true, It.IsAny <JsonConverter[]>())).Returns(this.settings); this.pluginSettingService.Setup(x => x.Read <RequirementsModuleSettings>(false)).Returns(this.settings); this.reqIfSerialiser = new Mock <IReqIFDeSerializer>(); this.reqIfSerialiser.Setup(x => x.Deserialize(It.IsAny <string>(), It.IsAny <bool>(), null)).Returns(new[] { this.reqIf }); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString()); 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.dialog = new ReqIfImportDialogViewModel(new[] { this.session.Object }, new[] { this.iteration }, this.fileDialogService.Object, this.pluginSettingService.Object, this.reqIfSerialiser.Object); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir); }