Exemplo n.º 1
0
        /// <summary>
        /// Execute the creation of a <see cref="ModellingAnnotationItem"/>
        /// </summary>
        protected void ExecuteCreateEngineeringModelDataNoteCommand(EngineeringModelDataNote engineeringModelDataNote, Participant participant, DomainOfExpertise owner)
        {
            if (this.SelectedThing == null)
            {
                return;
            }

            engineeringModelDataNote.Author = participant;
            var annotatedThing = new ModellingThingReference(this.SelectedThing.Thing);

            engineeringModelDataNote.RelatedThing.Add(annotatedThing);
            engineeringModelDataNote.PrimaryAnnotatedThing = annotatedThing;

            var transactionContext = TransactionContextResolver.ResolveContext(this.Thing);
            var model = this.Thing.TopContainer as EngineeringModel;

            if (model == null)
            {
                throw new InvalidOperationException("A modelling annotation item can only be created in the context of a Engineering Model.");
            }

            var containerClone = model.Clone(false);
            var transaction    = new ThingTransaction(transactionContext, containerClone);

            this.ThingDialogNavigationService.Navigate(engineeringModelDataNote, transaction, this.Session, true, ThingDialogKind.Create, this.ThingDialogNavigationService, containerClone);
        }
Exemplo n.º 2
0
        public void Setup()
        {
            this.assembler = new Assembler(this.uri);

            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString);

            this.siteDirectory            = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.siteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.siteDirectory.SiteReferenceDataLibrary.Add(this.siteReferenceDataLibrary);

            this.modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.siteReferenceDataLibrary
            };

            this.model      = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "model"
            };
            this.modelSetup.RequiredRdl.Add(this.modelReferenceDataLibrary);

            this.iteration      = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.reqSpec        = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "rs1", ShortName = "1"
            };

            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "test"
            };
            this.reqSpec.Owner = this.domain;

            this.iteration.RequirementsSpecification.Add(this.reqSpec);
            this.iteration.IterationSetup    = this.iterationSetup;
            this.model.EngineeringModelSetup = this.modelSetup;
            this.model.Iteration.Add(this.iteration);
            this.categories = new List <Category>()
            {
                new Category {
                    Name = "category1"
                }, new Category {
                    Name = "category2"
                }
            };

            this.grp1  = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.grp11 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.grp2  = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.reqSpec.Group.Add(this.grp1);
            this.reqSpec.Group.Add(this.grp2);
            this.grp1.Group.Add(this.grp11);

            this.req = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "requirement1", ShortName = "r1", Owner = this.domain, Category = this.categories
            };
            this.def = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Content = "def"
            };
            this.reqSpec.Requirement.Add(this.req);
            this.req.Definition.Add(this.def);
        }
Exemplo n.º 3
0
        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.Add(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.dialog = new SpecificationTypeMappingDialogViewModel(new List <SpecType> {
                this.spectype
            }, new Dictionary <DatatypeDefinition, DatatypeDefinitionMap> {
                { this.stringDatadef, new DatatypeDefinitionMap(this.stringDatadef, this.pt, null) }
            }, null, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, "en");
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ElementDefinitionRowViewModel"/> class
 /// </summary>
 /// <param name="elementDefinition">The associated <see cref="ElementDefinition"/></param>
 /// <param name="currentDomain">The active <see cref="DomainOfExpertise"/></param>
 /// <param name="session">The associated <see cref="ISession"/></param>
 /// <param name="containerViewModel">The container view-model</param>
 public ElementDefinitionRowViewModel(ElementDefinition elementDefinition, DomainOfExpertise currentDomain, ISession session, IViewModelBase <Thing> containerViewModel)
     : base(elementDefinition, currentDomain, session, containerViewModel)
 {
     this.UpdateProperties();
 }
Exemplo n.º 5
0
        public void Setup()
        {
            this.assembler         = new Assembler(this.uri);
            this.permissionService = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);
            this.thingDialognavigationService = new Mock <IThingDialogNavigationService>();
            this.session = new Mock <ISession>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.state1    = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "state1"
            };
            this.state2 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "state2"
            };

            this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.posStateList.PossibleState.Add(this.state1);
            this.posStateList.PossibleState.Add(this.state2);
            this.posStateList.DefaultState = this.state1;

            this.actualState1 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    this.state1
                },
                Kind = ActualFiniteStateKind.MANDATORY
            };

            this.actualState2 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    this.state2
                },
                Kind = ActualFiniteStateKind.MANDATORY
            };

            this.stateList.ActualState.Add(this.actualState1);
            this.stateList.ActualState.Add(this.actualState2);

            this.stateList.PossibleFiniteStateList.Add(this.posStateList);

            this.option1 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "option1"
            };
            this.option2 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "option2"
            };

            this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name      = "PTName",
                ShortName = "PTShortName"
            };

            this.enum1 = new EnumerationValueDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "enum1"
            };
            this.enum2 = new EnumerationValueDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "enum2"
            };
            this.enumPt = new EnumerationParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.enumPt.ValueDefinition.Add(this.enum1);
            this.enumPt.ValueDefinition.Add(this.enum2);

            this.cptType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name      = "APTName",
                ShortName = "APTShortName"
            };

            this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Iid           = Guid.NewGuid(),
                ParameterType = this.qqParamType,
                ShortName     = "c1"
            });

            this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Iid           = Guid.NewGuid(),
                ParameterType = this.enumPt,
                ShortName     = "c2"
            });

            this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "active", ShortName = "active"
            };
            this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "other", ShortName = "other"
            };

            this.parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner         = this.activeDomain,
                ParameterType = this.qqParamType
            };

            this.cptParameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner             = this.activeDomain,
                ParameterType     = this.cptType,
                IsOptionDependent = true,
                StateDependence   = this.stateList
            };

            this.valueset1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ActualOption = this.option1,
                ActualState  = this.stateList.ActualState.First()
            };

            this.valueset2 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ActualOption = this.option1,
                ActualState  = this.stateList.ActualState.Last()
            };

            this.valueset3 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ActualOption = this.option2,
                ActualState  = this.stateList.ActualState.First()
            };

            this.valueset4 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ActualOption = this.option2,
                ActualState  = this.stateList.ActualState.Last()
            };

            this.cptParameter.ValueSet.Add(this.valueset1);
            this.cptParameter.ValueSet.Add(this.valueset2);
            this.cptParameter.ValueSet.Add(this.valueset3);
            this.cptParameter.ValueSet.Add(this.valueset4);

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = this.activeDomain
            };
            this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ElementDefinition = this.elementDefinitionForUsage1
            };

            this.elementDefinition.ContainedElement.Add(this.elementUsage1);

            this.elementDefinitionForUsage1.Parameter.Add(this.parameter);
            this.elementDefinitionForUsage1.Parameter.Add(this.cptParameter);

            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iteration.Element.Add(this.elementDefinition);
            this.iteration.Element.Add(this.elementDefinitionForUsage1);

            this.iteration.Option.Add(this.option1);
            this.iteration.Option.Add(this.option2);

            this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.model.Iteration.Add(this.iteration);

            this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                GivenName = "test", Surname = "test"
            };
            this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Person = this.person, SelectedDomain = this.activeDomain
            };
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup.Participant.Add(this.participant);
            this.model.EngineeringModelSetup = this.modelsetup;

            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
        }
Exemplo n.º 6
0
        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.Add(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);
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.assembler         = new Assembler(this.uri);
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);

            this.officeApplicationWrapper = new Mock <IOfficeApplicationWrapper>();

            // inputs
            this.sitedir          = new SiteDirectory(Guid.NewGuid(), null, this.uri);
            this.modelSetup       = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri);
            this.iterationSetup   = new IterationSetup(Guid.NewGuid(), null, this.uri);
            this.person           = new Person(Guid.NewGuid(), null, this.uri);
            this.domain           = new DomainOfExpertise(Guid.NewGuid(), null, this.uri);
            this.domain.ShortName = "SYS";

            this.participant = new Participant(Guid.NewGuid(), null, this.uri)
            {
                Person = this.person
            };

            this.sitedir.Model.Add(this.modelSetup);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.modelSetup.IterationSetup.Add(this.iterationSetup);
            this.modelSetup.Participant.Add(this.participant);

            this.model = new EngineeringModel(Guid.NewGuid(), null, this.uri)
            {
                EngineeringModelSetup = this.modelSetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), null, this.uri)
            {
                IterationSetup = this.iterationSetup
            };

            this.model.Iteration.Add(this.iteration);

            var siteDirectory = new Lazy <Thing>(() => this.sitedir);

            this.assembler.Cache.GetOrAdd(new CacheKey(siteDirectory.Value.Iid, null), siteDirectory);
            this.session.Setup(x => x.DataSourceUri).Returns("test");
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);

            this.panelNavigationService = new Mock <IPanelNavigationService>();
            this.amountOfRibbonControls = 4;
            this.order = 1;

            // Setup negative dialog result - selection of iterationsetup
            this.SetupNegativeDialogResult();
            this.positiveDialogNavigationService = new Mock <IDialogNavigationService>();
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >
            {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, null) }
            });
        }
Exemplo n.º 8
0
        public virtual void Setup()
        {
            this.Assembler = new Assembler(this.Uri);

            this.Domain = new DomainOfExpertise(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                ShortName = "test"
            };

            this.Person = new Person(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                DefaultDomain = this.Domain
            };

            this.Participant = new Participant(Guid.NewGuid(), this.Assembler.Cache, this.Uri);

            this.Option = new Option(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                Name = "TestOption",
            };

            this.SetupElements();

            this.ElementUsage = new ElementUsage(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                Name              = "testName",
                ShortName         = "testShortName",
                Owner             = this.Domain,
                ElementDefinition = this.ElementDefinition1,
                Category          = new List <Category>()
                {
                    new Category(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
                    {
                        ShortName = "Test"
                    }
                }
            };

            this.NestedElement = new NestedElement(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                RootElement  = this.TopElement,
                Container    = this.Option,
                ElementUsage = new OrderedItemList <ElementUsage>(null)
                {
                    this.ElementUsage1
                }
            };

            this.EngineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                Name        = "test",
                Participant = { new Participant(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
                                {
                                    Person = this.Person
                                } }
            };

            this.EngineeringModel = new EngineeringModel(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                EngineeringModelSetup = this.EngineeringModelSetup
            };

            this.IterationSetup = new IterationSetup(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                IterationNumber = int.MaxValue
            };

            this.Iteration = new Iteration(Guid.NewGuid(), this.Assembler.Cache, this.Uri)
            {
                IterationSetup = this.IterationSetup,
                TopElement     = this.TopElement, DefaultOption = this.Option
            };

            this.Iteration.Option.Add(this.Option);
            this.AddThingsToTheCache();
            this.EngineeringModel.Iteration.Add(this.Iteration);
            this.Session = new Mock <ISession>();
            this.Session.Setup(x => x.Assembler).Returns(this.Assembler);
            this.Session.Setup(x => x.ActivePerson).Returns(this.Person);
            this.Session.Setup(x => x.QuerySelectedDomainOfExpertise(this.Iteration)).Returns(this.Domain);
        }
Exemplo n.º 9
0
        public void SetUp()
        {
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.iteration = new Iteration(Guid.NewGuid(), this.cache, null);

            this.model = new EngineeringModel(Guid.NewGuid(), null, null);
            this.model.Iteration.Add(this.iteration);

            var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, null);
            var iterationSetup            = new IterationSetup(Guid.NewGuid(), this.cache, null);
            var engineeringModelSetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, null);

            this.model.EngineeringModelSetup = engineeringModelSetup;

            iterationSetup.Container         = engineeringModelSetup;
            this.model.EngineeringModelSetup = engineeringModelSetup;
            engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary);

            this.iteration.IterationSetup = iterationSetup;
            this.iteration.Container      = this.model;

            // Option

            this.option = new Option(Guid.NewGuid(), this.cache, null)
            {
                ShortName = "option1",
                Name      = "option1"
            };

            this.iteration.Option.Add(this.option);

            this.actualFiniteState1 = new ActualFiniteState(Guid.NewGuid(), null, null);
            this.actualFiniteState2 = new ActualFiniteState(Guid.NewGuid(), null, null);
            this.actualList         = new ActualFiniteStateList(Guid.NewGuid(), null, null);
            this.actualList.Owner   = new DomainOfExpertise(Guid.NewGuid(), null, null);

            this.possibleList = new PossibleFiniteStateList(Guid.NewGuid(), null, null);

            this.possibleState1 = new PossibleFiniteState(Guid.NewGuid(), null, null)
            {
                Name = "possiblestate1", ShortName = "state1"
            };
            this.possibleState2 = new PossibleFiniteState(Guid.NewGuid(), null, null)
            {
                Name = "possiblestate2", ShortName = "state2"
            };

            this.possibleList.PossibleState.Add(this.possibleState1);
            this.possibleList.PossibleState.Add(this.possibleState2);

            this.actualFiniteState1.PossibleState.Add(this.possibleState1);
            this.actualFiniteState2.PossibleState.Add(this.possibleState2);

            this.actualList.PossibleFiniteStateList.Add(this.possibleList);

            this.iteration.ActualFiniteStateList.Add(this.actualList);
            this.iteration.PossibleFiniteStateList.Add(this.possibleList);
            this.actualList.ActualState.Add(this.actualFiniteState1);
            this.actualList.ActualState.Add(this.actualFiniteState2);

            // Categories

            this.cat1 = new Category(Guid.NewGuid(), this.cache, null)
            {
                ShortName = "cat1",
                Name      = "cat1"
            };

            modelReferenceDataLibrary.DefinedCategory.Add(this.cat1);

            this.cache.TryAdd(
                new CacheKey(this.cat1.Iid, null),
                new Lazy <Thing>(() => this.cat1));

            this.cat2 = new Category(Guid.NewGuid(), this.cache, null)
            {
                ShortName = "cat2",
                Name      = "cat2"
            };

            modelReferenceDataLibrary.DefinedCategory.Add(this.cat2);

            this.cache.TryAdd(
                new CacheKey(this.cat2.Iid, null),
                new Lazy <Thing>(() => this.cat2));

            // Domains of expertise

            this.elementOwner = new DomainOfExpertise(Guid.NewGuid(), null, null)
            {
                ShortName = "owner",
                Name      = "element owner"
            };

            this.parameterOwner = new DomainOfExpertise(Guid.NewGuid(), null, null)
            {
                ShortName = "owner1",
                Name      = "parameter owner"
            };

            this.parameterOverrideOwner = new DomainOfExpertise(Guid.NewGuid(), null, null)
            {
                ShortName = "owner2",
                Name      = "parameter override owner"
            };

            // Scale

            this.scale = new RatioScale(Guid.NewGuid(), this.cache, null)
            {
                ShortName = "scale",
                Name      = "scale"
            };

            // Parameter types

            this.parameterType1 = new SimpleQuantityKind(Guid.NewGuid(), null, null)
            {
                ShortName = "type1",
                Name      = "parameter type 1"
            };

            this.parameterType2 = new SimpleQuantityKind(Guid.NewGuid(), null, null)
            {
                ShortName = "type2",
                Name      = "parameter type 2"
            };

            this.parameterType3 = new SimpleQuantityKind(Guid.NewGuid(), null, null)
            {
                ShortName = "type3",
                Name      = "parameter type 3"
            };

            this.parameterType4 = new SimpleQuantityKind(Guid.NewGuid(), null, null)
            {
                ShortName = "type4",
                Name      = "parameter type 4",
            };

            // Element Definitions

            this.ed1 = new ElementDefinition(Guid.NewGuid(), this.cache, null)
            {
                ShortName = "ed1",
                Name      = "element definition 1",
                Owner     = this.elementOwner
            };

            this.AddParameter(this.ed1, this.parameterType1, this.parameterOwner, "11");
            this.AddParameter(this.ed1, this.parameterType2, this.parameterOwner, "12");
            this.AddParameter(this.ed1, this.parameterType3, this.parameterOwner, "13");
            this.AddStateDependentParameter(this.ed1, this.parameterType4, this.parameterOwner, this.actualList, "14");

            this.ed2 = new ElementDefinition(Guid.NewGuid(), this.cache, null)
            {
                ShortName = "ed2",
                Name      = "element definition 2",
                Owner     = this.elementOwner
            };

            var parameter1 = this.AddParameter(this.ed2, this.parameterType1, this.elementOwner, "-21");
            var parameter2 = this.AddParameter(this.ed2, this.parameterType2, this.elementOwner, "-22");
            var parameter3 = this.AddParameter(this.ed2, this.parameterType3, this.elementOwner, "-23");

            // Element Usages

            this.eu1 = new ElementUsage(Guid.NewGuid(), this.cache, null)
            {
                ElementDefinition = this.ed2,
                ShortName         = "eu1",
                Name  = "element usage 1",
                Owner = this.elementOwner
            };

            this.AddParameterOverride(this.eu1, this.parameterType1, this.parameterOverrideOwner, parameter1.ValueSet.First(), "121");
            this.AddParameterOverride(this.eu1, this.parameterType2, this.parameterOverrideOwner, parameter2.ValueSet.First(), "122");
            this.AddParameterOverride(this.eu1, this.parameterType3, this.parameterOverrideOwner, parameter3.ValueSet.First(), "123");

            this.eu2 = new ElementUsage(Guid.NewGuid(), this.cache, null)
            {
                ElementDefinition = this.ed2,
                ShortName         = "eu2",
                Name  = "element usage 2",
                Owner = this.elementOwner
            };

            // Structure

            this.iteration.TopElement = this.ed1;
            this.ed1.Category.Add(this.cat1);

            this.eu1.Category.Add(this.cat2);
            this.ed1.ContainedElement.Add(this.eu1);

            this.eu2.Category.Add(this.cat2);
            this.ed1.ContainedElement.Add(this.eu2);

            this.iteration.Element.Add(this.ed1);
            this.iteration.Element.Add(this.ed2);
        }
Exemplo n.º 10
0
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();

            this.systemDomainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "system", ShortName = "SYS"
            };
            this.aocsDomainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "aocs", ShortName = "AOCS"
            };

            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);

            engineeringModelSetup.ActiveDomain.Add(this.systemDomainOfExpertise);
            engineeringModelSetup.ActiveDomain.Add(this.aocsDomainOfExpertise);

            var srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "testRDL", ShortName = "test"
            };
            var category = new Category(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "test Category", ShortName = "testCategory"
            };

            category.PermissibleClass.Add(ClassKind.ElementDefinition);
            srdl.DefinedCategory.Add(category);
            var mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = srdl
            };

            engineeringModelSetup.RequiredRdl.Add(mrdl);
            srdl.DefinedCategory.Add(new Category(Guid.NewGuid(), this.cache, this.uri));
            this.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.engineeringModel.EngineeringModelSetup = engineeringModelSetup;
            var iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);

            this.engineeringModel.Iteration.Add(iteration);
            this.ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri);
            iteration.RuleVerificationList.Add(this.ruleVerificationList);

            this.cache.TryAdd(new CacheKey(iteration.Iid, null), new Lazy <Thing>(() => iteration));
            this.iterationClone = iteration.Clone(false);

            var transactionContext = TransactionContextResolver.ResolveContext(iteration);

            this.thingTransaction = new ThingTransaction(transactionContext, this.iterationClone);

            var dal = new Mock <IDal>();

            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);
            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());
        }
        public void SetUp()
        {
            this.uri   = new Uri("http://www.rheagroup.com");
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "SYS",
                Name      = "System"
            };

            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);

            var option_A = new Option(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "OPT_A",
                Name      = "Option A"
            };

            this.iteration.Option.Add(option_A);
            this.iteration.DefaultOption = option_A;

            var option_B = new Option(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "OPT_B",
                Name      = "Option B"
            };

            this.iteration.Option.Add(option_B);

            var satellite = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "Sat",
                Name      = "Satellite",
                Owner     = this.domainOfExpertise
            };

            this.iteration.Element.Add(satellite);
            this.iteration.TopElement = satellite;

            var battery = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "Bat",
                Name      = "Battery",
                Owner     = this.domainOfExpertise
            };

            this.iteration.Element.Add(battery);

            var battery_a = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ElementDefinition = battery,
                ShortName         = "bat_a",
                Name  = "battery a",
                Owner = this.domainOfExpertise
            };

            satellite.ContainedElement.Add(battery_a);

            var battery_b = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ElementDefinition = battery,
                ShortName         = "bat_b",
                Name  = "battery b",
                Owner = this.domainOfExpertise
            };

            battery_b.ExcludeOption.Add(option_A);

            satellite.ContainedElement.Add(battery_b);
        }
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();

            this.cache   = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();
            this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.srdl    = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl    = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.RequiredRdl.Add(this.mrdl);
            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.model.Iteration.Add(this.iteration);
            this.owner = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);
            this.sitedir.Domain.Add(this.owner);
            this.cat = new Category();
            this.cat.PermissibleClass.Add(ClassKind.PossibleFiniteStateList);
            this.srdl.DefinedCategory.Add(this.cat);
            this.modelsetup.ActiveDomain.Add(this.owner);

            this.possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "list1"
            };
            this.state11 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "s11"
            };
            this.state12 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "s12"
            };
            this.possibleList1.PossibleState.Add(this.state11);
            this.possibleList1.PossibleState.Add(this.state12);

            this.possibleList2 = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "list2"
            };
            this.state21 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "s21"
            };
            this.state22 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "s22"
            };
            this.possibleList2.PossibleState.Add(this.state21);
            this.possibleList2.PossibleState.Add(this.state22);

            this.actualList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            this.actualList.PossibleFiniteStateList.Add(this.possibleList1);
            this.actualList.PossibleFiniteStateList.Add(this.possibleList2);

            this.iteration.PossibleFiniteStateList.Add(this.possibleList1);
            this.iteration.PossibleFiniteStateList.Add(this.possibleList2);
            this.iteration.ActualFiniteStateList.Add(this.actualList);

            this.actualState1 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.actualState1.PossibleState.Add(this.state11);
            this.actualList.ActualState.Add(this.actualState1);

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.cache.TryAdd(new CacheKey(this.actualState1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.actualState1));
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);

            //this.session.Setup(x => x.Assembler.Cache
            var dal = new Mock <IDal>();

            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);
            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());
        }
        public void Setup()
        {
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.option    = new Option(Guid.NewGuid(), this.cache, this.uri)
            {
                Container = this.iteration
            };

            this.iteration.Option.Add(this.option);

            this.nestedElement  = new NestedElement(Guid.NewGuid(), this.cache, this.uri);
            this.rootElementDef = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementDef", ShortName = "Def", Container = this.iteration
            };
            this.elementDef1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementDef1", ShortName = "Def1", Container = this.iteration
            };
            this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementDef2", ShortName = "Def2", Container = this.iteration
            };
            this.elementDef3 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementDef3", ShortName = "Def3", Container = this.iteration
            };
            this.elementDef4 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementDef4", ShortName = "Def4", Container = this.iteration
            };
            this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementUsage", ShortName = "Use1", ElementDefinition = this.elementDef1
            };
            this.elementUsage2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementUsage2", ShortName = "Use2", ElementDefinition = this.elementDef2
            };
            this.elementUsage3_1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementUsage3_1", ShortName = "Use3_1", ElementDefinition = this.elementDef3
            };
            this.elementUsage3_2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementUsage3_2", ShortName = "Use3_2", ElementDefinition = this.elementDef3
            };
            this.elementUsage4 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "ElementUsage4", ShortName = "Use4", ElementDefinition = this.elementDef4
            };

            this.iteration.TopElement = this.rootElementDef;
            this.rootElementDef.ContainedElement.Add(this.elementUsage1);
            this.elementDef1.ContainedElement.Add(this.elementUsage2);
            this.elementDef1.ContainedElement.Add(this.elementUsage3_1);
            this.elementDef1.ContainedElement.Add(this.elementUsage3_2);
            this.elementDef3.ContainedElement.Add(this.elementUsage4);

            this.domain  = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);
            this.domain2 = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);

            this.elementUsage1.Owner             = this.domain2;
            this.elementUsage2.Owner             = this.domain2;
            this.elementUsage2.ElementDefinition = this.elementDef2;
            this.elementUsage3_1.Owner           = this.domain2;
            this.elementUsage3_2.Owner           = this.domain2;
            this.elementUsage4.Owner             = this.domain2;
            this.rootElementDef.Owner            = this.domain;

            this.nestedElement.RootElement = this.rootElementDef;
            this.nestedElement.ElementUsage.Add(this.elementUsage1);
            this.nestedElement.ElementUsage.Add(this.elementUsage2);

            this.category = new Category(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "Category", ShortName = "Cat"
            };

            var lazyCategory = new Lazy <Thing>(() => this.category);

            this.cache.TryAdd(new CacheKey(this.category.Iid, null), lazyCategory);

            var iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);

            this.iteration.IterationSetup = iterationSetup;

            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);

            engineeringModelSetup.IterationSetup.Add(iterationSetup);

            var modelReferenceLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);

            modelReferenceLibrary.DefinedCategory.Add(this.category);
            engineeringModelSetup.RequiredRdl.Add(modelReferenceLibrary);
        }
 /// <summary>
 /// Add a new row that represents a <see cref="DomainOfExpertise"/> to the list of <see cref="DomainOfExpertise"/>.
 /// </summary>
 /// <param name="domainOfExpertise">
 /// The <see cref="DomainOfExpertise"/> that is to be added.
 /// </param>
 private void AddDomainOfExpertise(DomainOfExpertise domainOfExpertise)
 {
     var vm = new DomainOfExpertiseRowViewModel(domainOfExpertise, this.Session, this);
     this.DomainOfExpertises.Add(vm);
 }
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.serviceLocator               = new Mock <IServiceLocator>();
            this.permissionService            = new Mock <IPermissionService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.pluginSettingsService        = new Mock <IPluginSettingsService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.session   = new Mock <ISession>();
            this.assembler = new Assembler(this.uri);

            this.session2   = new Mock <ISession>();
            this.assembler2 = new Assembler(this.uri2);

            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IPermissionService>()).Returns(this.permissionService.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IPanelNavigationService>()).Returns(this.panelNavigationService.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IThingDialogNavigationService>()).Returns(this.thingDialogNavigationService.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IDialogNavigationService>()).Returns(this.dialogNavigationService.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IPluginSettingsService>()).Returns(this.pluginSettingsService.Object);

            this.siteDir        = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.model          = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelSetup     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iteration      = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iteration2     = new Iteration(Guid.NewGuid(), this.assembler2.Cache, this.uri2);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.participant    = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.option         = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.siteDir.Person.Add(this.person);
            this.siteDir.Model.Add(this.modelSetup);
            this.modelSetup.IterationSetup.Add(this.iterationSetup);
            this.modelSetup.Participant.Add(this.participant);
            this.participant.Person = this.person;
            this.domainOfExpertise  = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.model.Iteration.Add(this.iteration);
            this.model.Iteration.Add(this.iteration2);
            this.model.EngineeringModelSetup = this.modelSetup;
            this.iteration.IterationSetup    = this.iterationSetup;
            this.iteration.Option.Add(this.option);
            this.iteration2.IterationSetup = this.iterationSetup;
            this.iteration2.Option.Add(this.option);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session2.Setup(x => x.Assembler).Returns(this.assembler2);
            this.session.Setup(x => x.IsVersionSupported(It.IsAny <Version>())).Returns(true);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);

            var openIterations = new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >();

            openIterations.Add(this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domainOfExpertise, this.participant));

            this.session.Setup(x => x.OpenIterations).Returns(openIterations);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Process the <see cref="ParameterGroup"/>s are that virtually contained by the <see cref="ParameterGroup"/> that is represented by the current excel row
 /// </summary>
 /// <param name="parameterGroups">The <see cref="ParameterGroup"/>s that are virtually contained by the <see cref="ParameterGroup"/>.</param>
 /// <param name="owner">
 /// The <see cref="DomainOfExpertise"/> that is the owner of any Parameter, ParameterSubscriptions or ParameterOverrides
 /// in the <see cref="ParameterGroup"/> that is represented by the current row.
 /// </param>
 /// <param name="processedValueSets">
 /// The <see cref="Thing"/>s for which the values need to be restored to what the user provided.
 /// </param>
 private void ProcessParameterGroups(IEnumerable <ParameterGroup> parameterGroups, DomainOfExpertise owner, IReadOnlyDictionary <Guid, ProcessedValueSet> processedValueSets)
 {
     foreach (var parameterGroup in parameterGroups)
     {
         var row = new ParameterGroupExcelRow(parameterGroup, owner, processedValueSets);
         this.ContainedRows.Add(row);
         row.Container = this;
     }
 }
Exemplo n.º 17
0
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.assembler                    = new Assembler(this.uri);
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.cache = this.assembler.Cache;
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);

            this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.srdl    = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl    = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);


            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain", ShortName = "DMN"
            };
            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = this.person, SelectedDomain = this.domain
            };

            this.modelsetup.ActiveDomain = new List <DomainOfExpertise>()
            {
                this.domain
            };
            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.modelsetup.Participant.Add(this.participant);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.model.Iteration.Add(this.iteration);
            this.elementDefinition1      = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);
            this.elementDefinition1.Name = "E1";
            this.elementDefinition2      = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);
            this.elementDefinition2.Name = "E2";
            this.elementDefinition3      = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);
            this.elementDefinition3.Name = "E3";
            this.elementDefinition4      = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);
            this.elementDefinition4.Name = "E4";
            this.elementDefinition5      = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);
            this.elementDefinition5.Name = "E5";

            this.iteration.Element.Add(this.elementDefinition1);
            this.iteration.Element.Add(this.elementDefinition2);
            this.iteration.Element.Add(this.elementDefinition3);
            this.iteration.Element.Add(this.elementDefinition4);
            this.iteration.Element.Add(this.elementDefinition5);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.Write(It.IsAny <OperationContainer>())).Returns(Task.FromResult("some result"));
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) }
            });

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
        }
        private void BuildSiteDirData()
        {
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);

            this.assembler = new Assembler(this.uri);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);

            this.siteDir         = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup1     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup2     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup1 = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup2 = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.person          = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.participant1    = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.participant2    = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain1         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain2         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain3         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.srdl1 = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl2 = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl1 = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl2 = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.category  = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.booleanPt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.srdl2.RequiredRdl = this.srdl1;
            this.mrdl1.RequiredRdl = this.srdl2;
            this.mrdl2.RequiredRdl = this.srdl1;

            this.participant1.Person = this.person;
            this.participant2.Person = this.person;

            this.modelsetup1.ActiveDomain.Add(this.domain1);
            this.modelsetup1.ActiveDomain.Add(this.domain2);
            this.modelsetup1.ActiveDomain.Add(this.domain3);
            this.modelsetup2.ActiveDomain.Add(this.domain1);
            this.modelsetup2.ActiveDomain.Add(this.domain2);

            this.srdl1.ParameterType.Add(this.booleanPt);
            this.srdl2.DefinedCategory.Add(this.category);

            this.siteDir.Model.Add(this.modelsetup1);
            this.siteDir.Model.Add(this.modelsetup2);
            this.siteDir.Person.Add(this.person);
            this.siteDir.Domain.Add(this.domain1);
            this.siteDir.Domain.Add(this.domain2);
            this.siteDir.Domain.Add(this.domain3);
            this.siteDir.SiteReferenceDataLibrary.Add(this.srdl1);
            this.siteDir.SiteReferenceDataLibrary.Add(this.srdl2);
            this.modelsetup1.IterationSetup.Add(this.iterationSetup1);
            this.modelsetup2.IterationSetup.Add(this.iterationSetup2);
            this.modelsetup1.Participant.Add(this.participant1);
            this.modelsetup2.Participant.Add(this.participant2);
            this.modelsetup1.RequiredRdl.Add(this.mrdl1);
            this.modelsetup2.RequiredRdl.Add(this.mrdl2);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.ActivePersonParticipants)
            .Returns(new List <Participant> {
                this.participant1, this.participant2
            });
        }
Exemplo n.º 19
0
        public void Setup()
        {
            var ensurePackSchemeIsKnown = PackUriHelper.UriSchemePack;

            this.session = new Mock <ISession>();
            this.cache   = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain", ShortName = "dom"
            };
            this.siteDirectory  = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.model          = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.modelSetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iteration      = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri)
            {
                GivenName = "test", Surname = "test"
            };
            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = this.person
            };
            this.option = new Option(Guid.NewGuid(), this.cache, this.uri);

            this.elementdef1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "Def1",
                Owner     = this.domain
            };

            this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName         = "Usage1",
                Container         = this.elementdef1,
                ElementDefinition = this.elementdef1,
                Owner             = this.domain
            };

            this.category1 = new Category(Guid.NewGuid(), this.cache, this.uri);
            this.category2 = new Category(Guid.NewGuid(), this.cache, this.uri);

            this.siteDirectory.Model.Add(this.modelSetup);
            this.modelSetup.IterationSetup.Add(this.iterationSetup);
            this.modelSetup.Participant.Add(this.participant);
            this.siteDirectory.Person.Add(this.person);

            this.model.Iteration.Add(this.iteration);
            this.model.EngineeringModelSetup = this.modelSetup;
            this.iteration.IterationSetup    = this.iterationSetup;
            this.iteration.Option.Add(this.option);
            this.iteration.Element.Add(this.elementdef1);

            this.parameterType1 = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "pt1", Category = new List <Category>()
                {
                    this.category1
                }
            };
            this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.parameterType1, Owner = this.domain
            };
            this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };
            this.state1   = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.valueset = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri);
            this.stateList.ActualState.Add(this.state1);
            this.elementdef1.Parameter.Add(this.parameter1);

            this.elementdef1.Category.Add(this.category1);
            this.elementUsage1.Category.Add(this.category2);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());

            this.cache.TryAdd(new CacheKey(this.parameter1.Iid, null), new Lazy <Thing>(() => this.parameter1));
            this.converter = new ProductTreeIconUriConverter();

            this.relationalExpression = new RelationalExpression();
            this.serviceLocator       = new Mock <IServiceLocator>();
            this.thingCreator         = new Mock <IThingCreator>();

            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

            this.nestedElementTreeService = new Mock <INestedElementTreeService>();
            this.nestedElementTreeService.Setup(x => x.GetNestedParameterPath(It.IsAny <ParameterBase>(), It.IsAny <Option>())).Returns(this.nestedParameterPath);

            this.serviceLocator.Setup(x => x.GetInstance <INestedElementTreeService>()).Returns(this.nestedElementTreeService.Object);

            this.serviceLocator.Setup(x => x.GetInstance <IThingCreator>())
            .Returns(this.thingCreator.Object);

            this.thingCreator.Setup(x => x.IsCreateBinaryRelationshipForRequirementVerificationAllowed(It.IsAny <ParameterOrOverrideBase>(), It.IsAny <RelationalExpression>()))
            .Returns(true);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DomainChangedEvent"/> class.
 /// </summary>
 /// <param name="iteration">
 /// The session.
 /// </param>
 /// <param name="domain">
 /// The status.
 /// </param>
 public DomainChangedEvent(Iteration iteration, DomainOfExpertise domain)
 {
     this.Iteration      = iteration;
     this.SelectedDomain = domain;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReqIfImportMappingManager"/> class
 /// </summary>
 /// <param name="reqif">The <see cref="ReqIF"/> object to map</param>
 /// <param name="session">The <see cref="ISession"/> in which are information shall be written</param>
 /// <param name="iteration">The <see cref="Iteration"/> in which the information shall be written</param>
 /// <param name="domain">The active <see cref="DomainOfExpertise"/></param>
 /// <param name="dialogNavigationService">The <see cref="IDialogNavigationService"/></param>
 /// <param name="thingDialogNavigationService">The <see cref="IThingDialogNavigationService"/></param>
 /// <param name="mappingConfiguration">The <see cref="ImportMappingConfiguration"/></param>
 public ReqIfImportMappingManager(ReqIF reqif, ISession session, Iteration iteration, DomainOfExpertise domain, IDialogNavigationService dialogNavigationService, IThingDialogNavigationService thingDialogNavigationService, ImportMappingConfiguration mappingConfiguration = null)
 {
     this.reqIf     = reqif;
     this.session   = session;
     this.iteration = iteration.Clone(false);
     this.dialogNavigationService      = dialogNavigationService;
     this.thingDialogNavigationService = thingDialogNavigationService;
     this.currentDomain        = domain;
     this.mappingConfiguration = mappingConfiguration ?? new ImportMappingConfiguration()
     {
         ReqIfName = this.reqIf.TheHeader?.Title, ReqIfId = this.reqIf.TheHeader?.Identifier
     };
 }
        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);
        }
        public void SetUp()
        {
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.uri = new Uri("http://www.rheagroup.com");

            this.session = new Mock <ISession>();

            this.domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "System",
                ShortName = "SYS"
            };

            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "TST",
                Name      = "Test Model"
            };

            this.EngineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = engineeringModelSetup
            };

            var iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationNumber = 1
            };

            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = iterationSetup
            };

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "SAT",
                Name      = "Satellite",
                Owner     = this.domainOfExpertise
            };

            this.iteration.Element.Add(this.elementDefinition);

            this.EngineeringModel.Iteration.Add(this.iteration);

            this.option = new Option(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "Option 1", ShortName = "option_1"
            };
            this.iteration.Option.Add(this.option);

            var person = new Person(Guid.NewGuid(), this.cache, this.uri)
            {
                GivenName = "John", Surname = "Doe"
            };


            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = person,
            };
            this.participant.Domain.Add(this.domainOfExpertise);
            engineeringModelSetup.Participant.Add(this.participant);

            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >
            {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domainOfExpertise, null) }
            });
        }
Exemplo n.º 24
0
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.assembler                    = new Assembler(this.uri);
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.cache = this.assembler.Cache;
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);

            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain", ShortName = "DMN"
            };
            this.otherDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "otherDomain", ShortName = "ODMN"
            };
            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = this.person, SelectedDomain = this.domain
            };

            this.modelsetup.ActiveDomain = new List <DomainOfExpertise>()
            {
                this.domain, this.otherDomain
            };

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);

            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.sitedir.Domain.Add(this.otherDomain);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.modelsetup.Participant.Add(this.participant);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.iteration.Element.Add(this.elementDefinition);
            this.publication = new Publication(Guid.NewGuid(), this.cache, this.uri);

            this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri)
                {
                    Name = "paramtype1", ShortName = "pat1"
                }, Owner = this.domain
            };
            this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri)
                {
                    Name = "paramtype2", ShortName = "pat2"
                }, Owner = this.domain
            };

            var parameterforoverride = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri)
                {
                    Name = "paramtype3", ShortName = "pat3"
                }
            };

            // Test input
            var valueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri);

            this.SetScalarValueSet(valueSet);
            parameterforoverride.ValueSet.Add(valueSet);

            parameter1.ValueSet.Add(valueSet.Clone(false));

            this.parameterOverride1 = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri)
            {
                Parameter = parameterforoverride
            };

            this.elementDefinition.Parameter.Add(this.parameter1);
            this.elementDefinition.Parameter.Add(this.parameter2);
            this.elementDefinition.Parameter.Add(parameterforoverride);

            var elementusage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri);

            this.elementDefinition.ContainedElement.Add(elementusage);
            elementusage.ParameterOverride.Add(this.parameterOverride1);

            this.publication.PublishedParameter.Add(this.parameter1);
            this.publication.PublishedParameter.Add(this.parameter2);
            this.publication.PublishedParameter.Add(this.parameterOverride1);

            this.publication.CreatedOn = DateTime.Now;
            this.publication.Domain.Add(this.domain);

            this.model.Iteration.Add(this.iteration);
            this.iteration.Publication.Add(this.publication);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.Write(It.IsAny <OperationContainer>())).Returns(Task.FromResult("some result"));
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
        }
        /// <summary>
        /// Update the <see cref="ThingTransaction"/> with updated <see cref="IOwnedThing"/>s
        /// </summary>
        /// <param name="transaction">
        ///  The subject <see cref="IThingTransaction"/> that is to be updated
        /// </param>
        /// <param name="ownedThings">
        /// The <see cref="IEnumerable{IOwnedThing}"/> whose ownership needs to be updated
        /// </param>
        /// <param name="owner">
        /// The <see cref="DomainOfExpertise"/> that is be the owner of the updated <see cref="IOwnedThing"/>s
        /// </param>
        private void UpdateTransactionWithUpdatedOwners(IThingTransaction transaction, IEnumerable <IOwnedThing> ownedThings, DomainOfExpertise owner)
        {
            foreach (var ownedThing in ownedThings)
            {
                var clone            = ((Thing)ownedThing).Clone(false);
                var clonedOwnedThing = (IOwnedThing)clone;
                clonedOwnedThing.Owner = owner;

                transaction.CreateOrUpdate(clone);
            }
        }
        public void Setup()
        {
            this.uri       = new Uri("https://test.test");
            this.assembler = new Assembler(this.uri);
            this.domain    = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.session   = new Mock <ISession>();
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.AbsoluteUri);

            this.iteration =
                new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Container = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
                {
                    EngineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
                    {
                        RequiredRdl = { new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri) },
                        Container   = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
                        {
                            Container = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri)
                        }
                    }
                }
            };

            this.hubController = new Mock <IHubController>();
            this.hubController.Setup(x => x.CurrentDomainOfExpertise).Returns(this.domain);
            this.hubController.Setup(x => x.Session).Returns(this.session.Object);
            this.hubController.Setup(x => x.OpenIteration).Returns(this.iteration);
            this.hubController.Setup(x => x.GetSiteDirectory()).Returns(new SiteDirectory());

            this.dstController = new Mock <IDstController>();
            this.dstController.Setup(x => x.ExternalIdentifierMap).Returns(new ExternalIdentifierMap());
            this.dstController.Setup(x => x.AddToExternalIdentifierMap(It.IsAny <Guid>(), It.IsAny <string>()));

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterInstance(this.hubController.Object).As <IHubController>();
            containerBuilder.RegisterInstance(this.dstController.Object).As <IDstController>();
            AppContainer.Container = containerBuilder.Build();

            this.actualFiniteStates = new ActualFiniteStateList()
            {
                ActualState =
                {
                    new ActualFiniteState(),
                    new ActualFiniteState()
                }
            };

            this.rule = new EcosimProElementToElementDefinitionRule();

            this.SetParameterTypes();

            this.variables = new List <VariableRowViewModel>()
            {
                new VariableRowViewModel((
                                             new ReferenceDescription()
                {
                    NodeId = new ExpandedNodeId(Guid.NewGuid()),
                    DisplayName = new LocalizedText(string.Empty, "Mos.a")
                },
                                             new DataValue()
                {
                    Value = 5, ServerTimestamp = DateTime.MinValue
                }))
                {
                    SelectedParameterType = this.scalarParameterType
                }
            };
        }
Exemplo n.º 27
0
        public void SetUp()
        {
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialognavigationService = new Mock <IThingDialogNavigationService>();
            this.thingCreator = new Mock <IThingCreator>();
            this.cache        = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };

            this.modelsetup.RequiredRdl.Add(this.mrdl);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);

            this.option1 = new Option(Guid.NewGuid(), this.cache, this.uri);
            this.option2 = new Option(Guid.NewGuid(), this.cache, this.uri);

            this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            this.state1    = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.state2    = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);

            this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            this.posStateList.PossibleState.Add(this.state1);
            this.posStateList.PossibleState.Add(this.state2);
            this.posStateList.DefaultState = this.state1;

            this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    this.state1
                },
                Kind = ActualFiniteStateKind.MANDATORY
            });

            this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    this.state2
                },
                Kind = ActualFiniteStateKind.FORBIDDEN
            });

            this.activeDomain    = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);
            this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);
            this.session         = new Mock <ISession>();
            this.qqParamType     = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "PTName",
                ShortName = "PTShortName"
            };

            // Array parameter type with components
            this.apType = new ArrayParameterType(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "APTName",
                ShortName = "APTShortName"
            };

            this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                Iid           = Guid.NewGuid(),
                ParameterType = this.qqParamType
            });

            this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                Iid           = Guid.NewGuid(),
                ParameterType = this.qqParamType
            });

            // compound parameter type with components
            this.cptType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "APTName",
                ShortName = "APTShortName"
            };

            this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                Iid           = Guid.NewGuid(),
                ParameterType = this.qqParamType
            });

            this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                Iid           = Guid.NewGuid(),
                ParameterType = this.qqParamType
            });

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.activeDomain
            };

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            var person = new Person(Guid.NewGuid(), null, null)
            {
                GivenName = "test", Surname = "test"
            };
            var participant = new Participant(Guid.NewGuid(), null, null)
            {
                Person = person, SelectedDomain = this.activeDomain
            };

            this.session.Setup(x => x.ActivePerson).Returns(person);
            this.modelsetup.Participant.Add(participant);
            this.model.Iteration.Add(this.iteration);
            this.iteration.Element.Add(this.elementDefinition);

            this.iteration.Option.Add(this.option1);
            this.iteration.Option.Add(this.option2);

            this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.someotherDomain
            };

            this.elementDefinitionForUsage2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.someotherDomain
            };

            this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.someotherDomain
            };

            this.elementUsage2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.someotherDomain
            };

            this.elementUsage1.ElementDefinition = this.elementDefinitionForUsage1;
            this.elementUsage2.ElementDefinition = this.elementDefinitionForUsage2;

            this.parameterGroup1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri);
            this.parameterGroup2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri);
            this.parameterGroup3 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri);

            this.parameterGroup1ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri);
            this.parameterGroup2ForUsage2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri);
            this.parameterGroup3ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri);

            this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.qqParamType,
                Owner         = this.activeDomain
            };

            this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.qqParamType,
                Owner         = this.activeDomain
            };

            this.parameter3 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.qqParamType,
                Owner         = this.someotherDomain
            };

            this.parameter4 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.qqParamType,
                Owner         = this.someotherDomain
            };

            this.parameterForStates = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType   = this.qqParamType,
                Owner           = this.someotherDomain,
                StateDependence = this.stateList
            };

            this.parameter5ForSubscription = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.qqParamType,
                Owner         = this.someotherDomain
            };

            this.parameter6ForOverride = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.qqParamType,
                Owner         = this.activeDomain
            };

            this.parameter6Override = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri)
            {
                Parameter = this.parameter6ForOverride,
                Owner     = this.activeDomain
            };

            this.parameterArray = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.apType,
                Owner         = this.someotherDomain
            };

            this.parameterCompound = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.cptType,
                Owner         = this.someotherDomain
            };

            this.parameterCompoundForSubscription = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.cptType,
                Owner         = this.someotherDomain
            };

            this.parameterSubscriptionCompound = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.activeDomain
            };

            this.parameterCompoundForSubscription.ParameterSubscription.Add(this.parameterSubscriptionCompound);

            this.parameterForOptions = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType     = this.cptType,
                Owner             = this.someotherDomain,
                IsOptionDependent = true
            };

            this.elementDefinition.ParameterGroup.Add(this.parameterGroup1);
            this.elementDefinition.ParameterGroup.Add(this.parameterGroup2);
            this.elementDefinition.ParameterGroup.Add(this.parameterGroup3);

            this.elementDefinitionForUsage1.ParameterGroup.Add(this.parameterGroup1ForUsage1);
            this.elementDefinitionForUsage2.ParameterGroup.Add(this.parameterGroup2ForUsage2);
            this.elementDefinitionForUsage1.ParameterGroup.Add(this.parameterGroup3ForUsage1);

            this.iteration.Element.Add(elementDefinitionForUsage1);
            this.iteration.Element.Add(elementDefinitionForUsage2);

            this.parameterGroup3.ContainingGroup          = this.parameterGroup1;
            this.parameterGroup3ForUsage1.ContainingGroup = this.parameterGroup1ForUsage1;

            this.parameter4.Group = this.parameterGroup3;
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());
        }
Exemplo n.º 28
0
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.session = new Mock <ISession>();

            this.domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "system", ShortName = "SYS"
            };

            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri);
            this.participant.Domain.Add(this.domainOfExpertise);

            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);

            engineeringModelSetup.ActiveDomain.Add(this.domainOfExpertise);
            var srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "testRDL", ShortName = "test"
            };
            var category = new Category(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "test Category", ShortName = "testCategory"
            };

            category.PermissibleClass.Add(ClassKind.ElementDefinition);
            srdl.DefinedCategory.Add(category);
            var mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = srdl
            };

            engineeringModelSetup.RequiredRdl.Add(mrdl);
            srdl.DefinedCategory.Add(new Category(Guid.NewGuid(), this.cache, this.uri));
            this.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.engineeringModel.EngineeringModelSetup = engineeringModelSetup;
            var iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = new IterationSetup()
            };

            this.engineeringModel.Iteration.Add(iteration);
            this.folder          = new Folder(Guid.NewGuid(), this.cache, this.uri);
            this.domainFileStore = new DomainFileStore(Guid.NewGuid(), this.cache, this.uri);
            this.domainFileStore.Folder.Add(this.folder);
            iteration.DomainFileStore.Add(this.domainFileStore);

            this.cache.TryAdd(new CacheKey(iteration.Iid, null), new Lazy <Thing>(() => iteration));

            this.domainFileStoreClone = this.domainFileStore.Clone(false);

            var transactionContext = TransactionContextResolver.ResolveContext(this.domainFileStore);

            this.thingTransaction = new ThingTransaction(transactionContext, this.domainFileStoreClone);

            var dal = new Mock <IDal>();

            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);

            var openIterations = new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >();

            openIterations.Add(iteration, new Tuple <DomainOfExpertise, Participant>(this.domainOfExpertise, this.participant));

            this.session.Setup(x => x.OpenIterations).Returns(openIterations);
            this.session.Setup(x => x.QueryCurrentDomainOfExpertise()).Returns(this.domainOfExpertise);

            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());
        }
Exemplo n.º 29
0
        /// <summary>
        /// Creates the <see cref="NestedParameter"/>s in a flat list from <see cref="NestedElement"/>s list for the of <see cref="NestedElement"/>s.
        /// </summary>
        /// <param name="option">
        /// The <see cref="Option"/> for which the <see cref="NestedParameter"/>s flat list is created. When the <see cref="Option"/>
        /// is null then none of the <see cref="ElementUsage"/>s are filtered.
        /// </param>
        /// <param name="domainOfExpertise">
        /// The <see cref="DomainOfExpertise"/> for which the <see cref="NestedParameter"/>s flat list needs to be generated. Only the <see cref="Parameter"/>s, <see cref="ParameterOverride"/>s and
        /// <see cref="ParameterSubscription"/>s that are owned by the <see cref="DomainOfExpertise"/> will be taken into account.
        /// </param>
        /// <param name="updateOption">
        /// Value indicating whether the <see cref="Option"/> shall be updated with the created <see cref="NestedElement"/>s or not.
        /// </param>
        /// <returns>
        /// An <see cref="IEnumerable{NestedParameter}"/> that contains the generated <see cref="NestedParameter"/>s
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// thrown when the <paramref name="option"/> is null
        /// </exception>
        private IEnumerable <NestedParameter> GetNestedParameters_Impl(Option option, DomainOfExpertise domainOfExpertise, bool updateOption)
        {
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option), "The option may not be null");
            }

            var iteration = (Iteration)option.Container;

            Logger.Debug($"Generating NestedElement for Iteration {iteration.Iid}, Option: {option.ShortName}, DomainOfExpertise {domainOfExpertise?.ShortName ?? ": All"}");

            var nestedElements = this.Generate_Impl(option, domainOfExpertise, updateOption);

            Logger.Debug($"Crearing NestedParameters Iteration: {iteration.Iid}, Option: {option.ShortName}, DomainOfExpertise {domainOfExpertise?.ShortName ?? ": All"}");

            var flatNestedParameters = nestedElements.SelectMany(np => np.NestedParameter);

            return(flatNestedParameters.ToList());
        }
Exemplo n.º 30
0
        private void InstantiateThings()
        {
            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IMetaDataProvider>()).Returns(new MetaDataProvider());

            this.assembler = new Assembler(this.credentials.Uri);
            this.session   = new Mock <ISession>();
            this.session.Setup(x => x.Credentials).Returns(this.credentials);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);

            this.siteDir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri);
            this.person  = new Person(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
            {
                Container = this.siteDir
            };
            this.siteDir.Person.Add(this.person);

            this.genericRdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
            {
                Name = "Generic RDL", ShortName = "GenRDL"
            };
            this.siteRdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
            {
                RequiredRdl = this.genericRdl
            };
            this.siteDir.SiteReferenceDataLibrary.Add(this.siteRdl);

            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
            {
                Container = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
                {
                    EngineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
                },
                IterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
                {
                    IterationNumber = 1
                }
            };

            var domain = new DomainOfExpertise(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                Name = "Domain"
            };

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                Name      = "ElementDefinition",
                ShortName = "ED",
                Container = this.iteration,
                Owner     = domain
            };

            this.parameterType = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
            {
                Name      = "SimpleQuantityKind",
                ShortName = "SQK",
            };

            this.siteRdl.ParameterType.Add(this.parameterType);

            var parameter = new CDP4Common.EngineeringModelData.Parameter(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri)
            {
                ParameterType = this.parameterType,
                Scale         = this.parameterType.DefaultScale,
                Owner         = domain
            };

            this.iteration.Element.Add(this.elementDefinition);
            this.iteration.Element.FirstOrDefault()?.Parameter.Add(parameter);
        }