public void VerifyThatExistingMapIsApplied() { var category = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.assembler.Cache, this.uri) { Category = category }; var binaryRelationshipRule = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri) { RelationshipCategory = category, TargetCategory = category, SourceCategory = category }; var categoryVm = new CategoryComboBoxItemViewModel(category, true); Dictionary <SpecRelationType, SpecRelationTypeMap> specRelationTypeMaps = null; var datatypeDefinitionMaps = new Dictionary <DatatypeDefinition, DatatypeDefinitionMap> { { this.stringDatadef, new DatatypeDefinitionMap(this.stringDatadef, this.pt, null) } }; var newDialog = new SpecRelationTypeMappingDialogViewModel(new List <SpecRelationType> { this.spectype }, specRelationTypeMaps, datatypeDefinitionMaps, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, "en"); Assert.IsEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedCategories)); Assert.IsNull(newDialog.SpecTypes[0].SelectedRules); Assert.IsNull(newDialog.SpecTypes[0].SelectedBinaryRelationshipRules); var row = newDialog.SpecTypes.First(); row.PossibleBinaryRelationshipRules.Add(binaryRelationshipRule); row.PossibleCategories.Add(categoryVm); row.PossibleRules.Add(rule); specRelationTypeMaps = new Dictionary <SpecRelationType, SpecRelationTypeMap>() { { this.spectype, new SpecRelationTypeMap( this.spectype, new[] { rule }, new[] { category }, new List <AttributeDefinitionMap>() { new AttributeDefinitionMap(this.attribute, AttributeDefinitionMapKind.SHORTNAME) }, new[] { binaryRelationshipRule }) } }; newDialog.PopulateRelationTypeMapProperties(specRelationTypeMaps); Assert.IsNotEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedCategories)); Assert.IsNotEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedRules)); Assert.IsNotEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedBinaryRelationshipRules)); }
/// <summary> /// NavigateModal to the <see cref="BinaryRelationship"/> mapping dialog /// </summary> private void NavigateToRelationshipDialog() { var dialog = new SpecRelationTypeMappingDialogViewModel(this.reqIf.CoreContent.Single().SpecTypes.OfType <SpecRelationType>(), this.specRelationTypeMap, this.datatypeDefinitionMap, this.iteration, this.session, this.thingDialogNavigationService, this.reqIf.Lang); var res = (RelationshipMappingDialogResult)this.dialogNavigationService.NavigateModal(dialog); // go back or mapping operation over. if (res == null || !res.Result.HasValue || !res.Result.Value) { return; } this.specRelationTypeMap = res.Map.ToDictionary(x => x.Key, x => x.Value); if (res.GoNext.HasValue && res.GoNext.Value) { this.NavigateToRequirementSpecificationMappingDialog(); } else if (res.GoNext.HasValue && !res.GoNext.Value) { this.NavigateToRelationshipGroupDialog(); } }
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); }