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); }