Пример #1
0
        /// <summary>
        /// NavigateModal to the <see cref="RequirementsSpecification"/> mapping dialog
        /// </summary>
        private void NavigateToRequirementSpecificationMappingDialog()
        {
            var typeMap = new Dictionary <SpecType, SpecTypeMap>();

            foreach (var specTypeMap in this.specificationTypeMap)
            {
                typeMap.Add(specTypeMap.Key, specTypeMap.Value);
            }

            foreach (var relationTypeMap in this.specRelationTypeMap)
            {
                typeMap.Add(relationTypeMap.Key, relationTypeMap.Value);
            }

            foreach (var map in this.specObjectTypeMap)
            {
                typeMap.Add(map.Key, map.Value);
            }

            foreach (var groupTypeMap in this.relationGroupTypeMap)
            {
                typeMap.Add(groupTypeMap.Key, groupTypeMap.Value);
            }

            var thingFactory = new ThingFactory(this.iteration, this.datatypeDefinitionMap, typeMap, this.currentDomain, this.reqIf.Lang);

            thingFactory.ComputeRequirementThings(this.reqIf);

            var dialog = new RequirementSpecificationMappingDialogViewModel(thingFactory, this.iteration, this.session, this.thingDialogNavigationService, this.reqIf.Lang);
            var res    = (MappingDialogNavigationResult)this.dialogNavigationService.NavigateModal(dialog);

            if (res == null || !res.Result.HasValue || !res.Result.Value)
            {
                return;
            }

            if (res.Result.Value && res.GoNext.HasValue && !res.GoNext.Value)
            {
                this.NavigateToRelationshipDialog();
            }
        }
        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
                                        } }
            };
            this.pluginSettingService = new Mock <IPluginSettingsService>();
            this.pluginSettingService.Setup(x => x.Read <RequirementsModuleSettings>(It.IsAny <bool>(), It.IsAny <JsonConverter[]>())).Returns(this.settings);
            this.pluginSettingService.Setup(x => x.Write(It.IsAny <PluginSettings>(), It.IsAny <JsonConverter[]>()));

            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.serviceLocator = new Mock <IServiceLocator>();
            this.serviceLocator.Setup(x => x.GetInstance <IPluginSettingsService>()).Returns(this.pluginSettingService.Object);
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

            var thingFactory = new ThingFactory(this.iteration, new Dictionary <DatatypeDefinition, DatatypeDefinitionMap>(), new Dictionary <SpecType, SpecTypeMap>(), this.domain);

            this.dialog = new RequirementSpecificationMappingDialogViewModel(thingFactory, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.dialogNavigationService.Object, "EN", this.settings.SavedConfigurations[0] as ImportMappingConfiguration);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }