public async Task GenerateTestObjects(EngineeringModelSetup engineeringModelSetup)
        {
            if (this.configuration == null)
            {
                this.NotifyMessage("Stress generator configuration is not initialized.", LogVerbosity.Error);
                return;
            }

            var session = this.configuration.Session;

            // Open session and retrieve SiteDirectory
            if (session.RetrieveSiteDirectory() == null)
            {
                await session.Open();

                session.RetrieveSiteDirectory();
            }

            // Read latest iteration
            await session.Refresh();

            var iteration = await ReadIteration(engineeringModelSetup);

            if (iteration == null)
            {
                return;
            }

            // Generate and write ElementDefinition list
            var generatedElementsList = await this.GenerateAndWriteElementDefinitions(iteration);

            // Refresh session
            await session.Refresh();

            // Generate and write ParameterValueSets
            await GenerateAndWriteParameterValueSets(generatedElementsList);

            // Close session
            await session.Close();
        }
        public void VerifyOkCommandWithoutSourceModel()
        {
            var engineeringModelSetup = new EngineeringModelSetup();

            var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
            var transaction        = new ThingTransaction(transactionContext, this.siteDirClone);

            this.viewModel = new EngineeringModelSetupDialogViewModel(engineeringModelSetup, transaction, this.session.Object, true, ThingDialogKind.Create, null, this.siteDirClone);

            Assert.That(this.viewModel["Name"], Is.Not.Null.Or.Empty);
            Assert.IsFalse(this.viewModel.OkCommand.CanExecute(null));

            var newShortName = "EMShortname";
            var newName      = "EMName";

            this.viewModel.ShortName  = newShortName;
            this.viewModel.Name       = newName;
            this.viewModel.StudyPhase = StudyPhaseKind.DESIGN_SESSION_PHASE;
            this.viewModel.SourceEngineeringModelSetup = null;
            var srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null)
            {
                Name = "testRDL", ShortName = "test"
            };

            this.viewModel.SelectedSiteReferenceDataLibrary = srdl;

            this.viewModel.OkCommand.Execute(null);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));
            Assert.IsNull(this.viewModel.WriteException);
            Assert.IsTrue(this.viewModel.DialogResult.Value);

            var clone = (EngineeringModelSetup)transaction.GetClone(engineeringModelSetup);

            Assert.AreEqual(newShortName, clone.ShortName);
            Assert.AreEqual(newName, clone.Name);
            Assert.AreEqual(StudyPhaseKind.DESIGN_SESSION_PHASE, clone.StudyPhase);
            Assert.IsNull(clone.SourceEngineeringModelSetupIid);
            Assert.AreEqual(1, clone.RequiredRdl.Count);
        }
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.session = new Mock <ISession>();
            this.uri     = new Uri("http://test.be");

            this.model      = new EngineeringModel(Guid.NewGuid(), null, this.uri);
            this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri)
            {
                Name = "model"
            };
            this.model.EngineeringModelSetup = this.modelSetup;

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

            this.model.Iteration.Add(this.iteration);
        }
Example #4
0
        /// <summary>
        /// The event-handler that is invoked by the subscription that listens for <see cref="EngineeringModelSetup"/>s added
        /// </summary>
        /// <param name="engineeringModelSetup">the engineering model setup.</param>
        protected virtual void EngineeringModelSetupAddedEventHandler(EngineeringModelSetup engineeringModelSetup)
        {
            var session = this.Sessions.SingleOrDefault(s => s.Assembler.Cache == engineeringModelSetup.Cache);

            if (session == null)
            {
                // no session associated found in this ribbon
                return;
            }

            var sessionEngineeringModelSetupMenuGroupViewModel = this.EngineeringModelSetups.SingleOrDefault(x => x.Thing == engineeringModelSetup.Container);

            if (sessionEngineeringModelSetupMenuGroupViewModel == null)
            {
                sessionEngineeringModelSetupMenuGroupViewModel = new SessionEngineeringModelSetupMenuGroupViewModel(engineeringModelSetup.Container as SiteDirectory, session);
                this.EngineeringModelSetups.Add(sessionEngineeringModelSetupMenuGroupViewModel);
            }

            var menuItem = new RibbonMenuItemEngineeringModelSetupDependentViewModel(engineeringModelSetup, session, this.InstantiatePanelViewModelFunction);

            sessionEngineeringModelSetupMenuGroupViewModel.EngineeringModelSetups.Add(menuItem);
        }
Example #5
0
        /// <summary>
        /// The event-handler that is invoked by the subscription that listens for <see cref="Iteration"/>s removed
        /// </summary>
        /// <param name="engineeringModelSetup">the engineering model setup</param>
        protected virtual void EngineeringModelSetupRemovedEventHandler(EngineeringModelSetup engineeringModelSetup)
        {
            var sessionEngineeringModelSetupMenuGroupViewModel = this.EngineeringModelSetups.SingleOrDefault(x => x.Thing == engineeringModelSetup.Container);

            if (sessionEngineeringModelSetupMenuGroupViewModel == null)
            {
                return;
            }

            var menuItemToRemove = sessionEngineeringModelSetupMenuGroupViewModel.EngineeringModelSetups.Single(x => x.EngineeringModelSetup == engineeringModelSetup);

            sessionEngineeringModelSetupMenuGroupViewModel.EngineeringModelSetups.Remove(menuItemToRemove);

            // removes the group if there are no more of its iterations opened
            if (sessionEngineeringModelSetupMenuGroupViewModel.EngineeringModelSetups.Count == 0)
            {
                this.EngineeringModelSetups.Remove(sessionEngineeringModelSetupMenuGroupViewModel);
            }

            menuItemToRemove.IsChecked = false;
            menuItemToRemove.ShowOrClosePanelCommand.Execute(null);
        }
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.uri = new Uri("http://www.rheagroup.com");
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();
            this.cache             = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.model   = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.domain  = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);
            this.person  = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.person.DefaultDomain = this.domain;
            this.role = new ParticipantRole(Guid.NewGuid(), this.cache, this.uri);

            this.sitedir.ParticipantRole.Add(this.role);
            this.sitedir.Model.Add(this.model);
            this.sitedir.Domain.Add(this.domain);
            this.sitedir.Person.Add(this.person);

            this.model.ActiveDomain.Add(this.domain);

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

            this.clone = this.model.Clone(false);

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

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

            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());
        }
Example #7
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.session   = new Mock <ISession>();
            this.uri       = new Uri("http://www.rheagroup.com");
            this.assembler = new Assembler(this.uri);

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

            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.thingCreator = new Mock <IThingCreator>();

            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.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.modelsetup.RequiredRdl.Add(this.mrdl);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);

            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.model.Iteration.Add(this.iteration);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
        }
Example #8
0
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            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.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);

            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.domainOfExpertise = new DomainOfExpertise {
                ShortName = "SYS", Name = "System"
            };
            this.session = new Mock <ISession>();
            this.session.Setup(x => x.QuerySelectedDomainOfExpertise(It.IsAny <Iteration>()))
            .Returns(this.domainOfExpertise);

            this.engineeringModelSetup = new EngineeringModelSetup {
                ShortName = "TST", Name = "Test"
            };
            this.iterationSetup = new IterationSetup {
                IterationNumber = 1
            };
            this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup);

            this.engineeringModel = new EngineeringModel {
                EngineeringModelSetup = this.engineeringModelSetup
            };
            this.iteration = new Iteration {
                IterationSetup = this.iterationSetup
            };
            this.engineeringModel.Iteration.Add(this.iteration);

            this.dateParameterType = new DateParameterType {
                ShortName = "LD", Name = "Launch Date"
            };
            this.ratioScale = new RatioScale {
                ShortName = "kg", Name = "kilogram"
            };
            this.simpleQuantityKind = new SimpleQuantityKind {
                ShortName = "m", Name = "mass"
            };
            this.booleanParameterType = new BooleanParameterType {
                ShortName = "C", Name = "Compliant"
            };
        }
Example #10
0
        public void VerifyThatSelectedParticipantAreDisplayedInProperty()
        {
            var viewmodel = new ModelBrowserViewModel(this.session.Object, this.session.Object.RetrieveSiteDirectory(), null, this.navigationService.Object, null, null);

            var model = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri);

            var testOrganization = new Organization(Guid.NewGuid(), null, this.uri)
            {
                Name = "RHEA"
            };
            var testDomain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri)
            {
                Name = "Thermal"
            };
            var participant = new Participant(Guid.NewGuid(), null, this.uri);

            participant.Domain.Add(testDomain);
            participant.Person = new Person(Guid.NewGuid(), null, this.uri)
            {
                GivenName = "blabla", Surname = "blabla", Organization = testOrganization
            };
            model.Participant.Add(participant);

            this.siteDirectory.Model.Add(model);
            revPropertyInfo.SetValue(this.siteDirectory, 50);

            CDPMessageBus.Current.SendObjectChangeEvent(this.siteDirectory, EventKind.Updated);

            var modelrow             = viewmodel.ModelSetup.First();
            var participantFolderRow = modelrow.ContainedRows.First();

            viewmodel.SelectedThing = participantFolderRow.ContainedRows.First();
            var participantRow = participantFolderRow.ContainedRows.First() as ModelParticipantRowViewModel;

            Assert.NotNull(participantRow);
            Assert.AreEqual("DoE: Thermal, Organization: RHEA", participantRow.Description);
            this.navigationService.Verify(x => x.Open(It.IsAny <Thing>(), this.session.Object));
        }
Example #11
0
        /// <summary>
        /// Update the properties of the current row-view-model
        /// </summary>
        private void UpdateProperties()
        {
            this.Domains               = new ReactiveList <DomainOfExpertise>(this.Thing.Domain);
            this.ParticipantRole       = this.Thing.Role;
            this.EngineeringModelSetup = (EngineeringModelSetup)this.Thing.Container;

            var person = this.Thing.Person;

            if (person == null)
            {
                return;
            }

            this.RowStatus = (this.Thing.IsActive && person.IsActive && !person.IsDeprecated)
                ? RowStatusKind.Active
                : RowStatusKind.Inactive;

            if (this.Role != null)
            {
                this.RoleName      = this.Role.Name;
                this.RoleShortName = this.Role.ShortName;
            }
        }
        public void VerifyThatWhenEngineeringModelSelectedCanOk()
        {
            var availableSessions = new List <ISession>();

            availableSessions.Add(this.session.Object);

            var siteDirectory = this.session.Object.Assembler.RetrieveSiteDirectory();

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

            engineeringModelSetup.Name      = "Test Model";
            engineeringModelSetup.ShortName = "testmodel";

            siteDirectory.Model.Add(engineeringModelSetup);

            var vm = new EngineeringModelSetupSelectionDialogViewModel(availableSessions);

            Assert.IsFalse(vm.OkCommand.CanExecute(null));

            vm.SelectedEngineeringModelSetup = engineeringModelSetup;

            Assert.IsTrue(vm.OkCommand.CanExecute(null));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RequirementsSpecificationEditorViewModel"/> class
        /// </summary>
        /// <param name="thing">The <see cref="RequirementsSpecification"/> that is represented by the current view-model</param>
        /// <param name="session">The session</param>
        /// <param name="thingDialogNavigationService">the <see cref="IThingDialogNavigationService"/></param>
        /// <param name="panelNavigationService">the <see cref="IPanelNavigationService"/></param>
        /// <param name="dialogNavigationService">The <see cref="IDialogNavigationService"/></param>
        public RequirementsSpecificationEditorViewModel(RequirementsSpecification thing, ISession session, IThingDialogNavigationService thingDialogNavigationService, IPanelNavigationService panelNavigationService, IDialogNavigationService dialogNavigationService, IPluginSettingsService pluginSettingsService)
            : base(thing, session, thingDialogNavigationService, panelNavigationService, dialogNavigationService, pluginSettingsService)
        {
            this.Caption = $"{PanelCaption}: {this.Thing.ShortName}";
            this.ToolTip = $"{this.Thing.Name}\n{this.Thing.IDalUri}\n{this.Session.ActivePerson.Name}";

            var model = (EngineeringModel)this.Thing.TopContainer;

            this.modelSetup = model.EngineeringModelSetup;

            var iteration = (Iteration)thing.Container;

            this.iterationSetup = iteration.IterationSetup;

            this.ContainedRows = new DisposableReactiveList <IRowViewModelBase <Thing> >();

            this.AddRequirementsSpecificationRow(thing);
            this.UpdateRequirementGroupRows();
            this.UpdateRequirementRows();

            this.AddSubscriptions();
            this.UpdateProperties();
        }
Example #14
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.serviceLocator    = new Mock <IServiceLocator>();
            this.messageBoxService = new Mock <IMessageBoxService>();

            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IMessageBoxService>()).Returns(this.messageBoxService.Object);

            this.session           = new Mock <ISession>();
            this.assembler         = new Assembler(this.uri);
            this.serializer        = new Mock <IReqIFSerializer>();
            this.fileDialogService = new Mock <IOpenSaveFileDialogService>();
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString());
            this.session.Setup(x => x.Assembler).Returns(this.assembler);

            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "model"
            };
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);

            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.model.Iteration.Add(this.iteration);
        }
Example #15
0
        public async Task Verify_that_opens_and_close_removes_items_from_cache()
        {
            this.dal = new CdpServicesDal {
                Session = this.session
            };
            this.credentials = new Credentials("admin", "pass", new Uri("https://cdp4services-public.cdp4.org"));

            this.session = new Session(dal, credentials);
            await this.session.Open();

            this.siteDirectory         = session.Assembler.RetrieveSiteDirectory();
            this.engineeringModelSetup = this.siteDirectory.Model.Single(x => x.ShortName == "LOFT");
            this.iterationSetup        = this.engineeringModelSetup.IterationSetup.First();
            var domainOfExpertise = this.engineeringModelSetup.ActiveDomain.First(x => x.ShortName == "SYS");

            var openCount = this.session.Assembler.Cache.Count;

            var cache = this.session.Assembler.Cache;

            var model = new EngineeringModel(this.engineeringModelSetup.EngineeringModelIid, null, null);

            this.iteration           = new Iteration(this.iterationSetup.IterationIid, null, null);
            this.iteration.Container = model;

            await this.session.Read(iteration, domainOfExpertise);

            var readCount = this.session.Assembler.Cache.Count;

            Assert.IsTrue(readCount > openCount);

            await this.session.CloseIterationSetup(this.iterationSetup);

            var closeCount = this.session.Assembler.Cache.Count;

            Assert.IsTrue(closeCount < readCount);
        }
        public void SetUp()
        {
            this.relationalExpressionRuleChecker = new RelationalExpressionRuleChecker();

            this.modelReferenceDataLibrary = new ModelReferenceDataLibrary();
            this.engineeringModelSetup     = new EngineeringModelSetup();
            this.engineeringModel          = new EngineeringModel();
            this.iteration = new Iteration();
            this.requirementsSpecification = new RequirementsSpecification();
            this.requirement          = new Requirement();
            this.parametricConstraint = new ParametricConstraint();
            this.relationalExpression = new RelationalExpression()
            {
                Iid = Guid.Parse("56d52d2f-fe41-4e35-8723-4fa310c254f3")
            };

            this.engineeringModelSetup.RequiredRdl.Add(this.modelReferenceDataLibrary);
            this.engineeringModel.EngineeringModelSetup = this.engineeringModelSetup;
            this.engineeringModel.Iteration.Add(this.iteration);
            this.iteration.RequirementsSpecification.Add(this.requirementsSpecification);
            this.requirementsSpecification.Requirement.Add(this.requirement);
            this.requirement.ParametricConstraint.Add(this.parametricConstraint);
            this.parametricConstraint.Expression.Add(this.relationalExpression);
        }
Example #17
0
        public void VerifyThatSelectedIterationSetupAreDisplayedInProperty()
        {
            var viewmodel = new ModelBrowserViewModel(this.session.Object, this.session.Object.RetrieveSiteDirectory(), null, this.navigationService.Object, null, null);

            var model = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri);

            var iteration = new IterationSetup(Guid.NewGuid(), null, this.uri);

            model.IterationSetup.Add(iteration);

            this.siteDirectory.Model.Add(model);
            revPropertyInfo.SetValue(this.siteDirectory, 50);

            CDPMessageBus.Current.SendObjectChangeEvent(this.siteDirectory, EventKind.Updated);

            var modelrow = viewmodel.ModelSetup.First();

            Assert.AreEqual("Phase: Preparation Phase, Kind: Study Model", modelrow.Description);
            var iterationFolderRow = modelrow.ContainedRows[1];

            viewmodel.SelectedThing = iterationFolderRow.ContainedRows.First();
            this.navigationService.Verify(x => x.Open(It.IsAny <Thing>(), this.session.Object));
            Assert.AreEqual("IterationSetup", viewmodel.SelectedThing.Thing.ClassKind.ToString());
        }
Example #18
0
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.uri   = new Uri("http://www.rheagroup.com");
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

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

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

            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            var dialogResult          = new EngineeringModelSetupSelectionResult(true, this.session.Object, engineeringModelSetup);

            this.dialogNavigationService.Setup(x => x.NavigateModal(It.IsAny <IDialogViewModel>())).Returns(dialogResult);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
        }
Example #19
0
        public void VerifyThatActiveDomainIsCorrectlyPopulated()
        {
            var domain1 = new DomainOfExpertise(Guid.NewGuid(), null, this.uri);
            var domain2 = new DomainOfExpertise(Guid.NewGuid(), null, this.uri);
            var domain3 = new DomainOfExpertise(Guid.NewGuid(), null, this.uri);

            this.siteDirClone.Domain.Add(domain1);
            this.siteDirClone.Domain.Add(domain2);
            this.siteDirClone.Domain.Add(domain3);

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

            engineeringModelSetup.ActiveDomain.Add(domain1);

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

            var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
            var transaction        = new ThingTransaction(transactionContext, this.siteDirClone);

            this.viewModel = new EngineeringModelSetupDialogViewModel(engineeringModelSetup.Clone(false), transaction, this.session.Object, true, ThingDialogKind.Update, null, this.siteDirClone);

            Assert.AreEqual(3, this.viewModel.PossibleActiveDomain.Count);
            Assert.AreEqual(1, this.viewModel.ActiveDomain.Count);
        }
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.uri         = new Uri("http://www.rheagroup.com");
            this.credentials = new Credentials("John", "Doe", this.uri);
            this.session     = new Mock <ISession>();

            this.siteDirectory = new SiteDirectory(Guid.NewGuid(), null, this.uri)
            {
                Name = "TestSiteDir"
            };
            var model1RDL = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null)
            {
                Name = "model1RDL"
            };
            var model2RDL = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null)
            {
                Name = "model2RDL"
            };

            this.model1 = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri)
            {
                Name = "model1"
            };
            this.model1.RequiredRdl.Add(model1RDL);
            this.model2 = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri)
            {
                Name = "model2"
            };
            this.model2.RequiredRdl.Add(model2RDL);
            this.iteration11 = new IterationSetup(Guid.NewGuid(), null, this.uri);
            this.iteration21 = new IterationSetup(Guid.NewGuid(), null, this.uri);
            this.person      = new Person(Guid.NewGuid(), null, this.uri)
            {
                GivenName = "testPerson"
            };
            this.participant = new Participant(Guid.NewGuid(), null, this.uri)
            {
                Person = this.person,
                Domain = { this.domain }
            };
            this.domain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri)
            {
                Name = "domaintest"
            };

            this.person.DefaultDomain = this.domain;
            this.model1.Participant.Add(this.participant);
            this.model2.Participant.Add(this.participant);

            this.model1.IterationSetup.Add(this.iteration11);
            this.model2.IterationSetup.Add(this.iteration21);

            this.siteDirectory.Model.Add(this.model1);
            this.siteDirectory.Model.Add(this.model2);
            this.siteDirectory.Person.Add(this.person);

            this.assembler = new Assembler(this.uri);

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

            this.assembler.Cache.GetOrAdd(new CacheKey(lazysiteDirectory.Value.Iid, null), lazysiteDirectory);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDirectory);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());
            this.session.Setup(x => x.Credentials).Returns(this.credentials);
        }
Example #21
0
        public void SetUp()
        {
            this.revision = typeof(Thing).GetProperty("RevisionNumber");

            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.serviceLocator       = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

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

            this.assembler = new Assembler(this.uri);
            this.cache     = this.assembler.Cache;


            this.serviceLocator.Setup(x => x.GetInstance <IPermissionService>()).Returns(this.permissionService.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IThingDialogNavigationService>()).Returns(this.thingDialogNavigationService.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IPanelNavigationService>()).Returns(this.panelNavigationService.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.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"
            };
            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = this.person, SelectedDomain = 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.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.session.Setup(x => x.IsVersionSupported(It.IsAny <Version>())).Returns(true);

            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
            });
        }
Example #23
0
        public virtual void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.filterStringService          = new Mock <IFilterStringService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();

            this.dialogNavigationService.Setup(x => x.NavigateModal(It.IsAny <ManageConfigurationsDialogViewModel>()))
            .Returns(new ManageConfigurationsResult(true));

            this.dialogNavigationService.Setup(x => x.NavigateModal(It.IsAny <SavedConfigurationDialogViewModel>()))
            .Returns(new SavedConfigurationResult(true));

            this.permissionService = new Mock <IPermissionService>();
            this.pluginService     = new Mock <IPluginSettingsService>();
            this.session           = new Mock <ISession>();
            this.serviceLocator.Setup(x => x.GetInstance <IFilterStringService>()).Returns(this.filterStringService.Object);

            this.assembler             = new Assembler(this.uri);
            this.sitedir               = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup        = new IterationSetup(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.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "domain", ShortName = "domain"
            };
            this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Person = this.person
            };

            this.catEd1 = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "cat1", ShortName = "cat1"
            };
            this.catEd2 = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "cat2", ShortName = "cat2"
            };
            this.catEd3 = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "cat3sub1", ShortName = "cat3sub1", SuperCategory = new List <Category> {
                    this.catEd1
                }
            };
            this.catEd4 = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "cat4sub3", ShortName = "cat3sub4", SuperCategory = new List <Category> {
                    this.catEd3
                }
            };
            this.catRel = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "catrel", ShortName = "catrel"
            };

            this.catEd1.PermissibleClass.Add(ClassKind.ElementDefinition);
            this.catEd2.PermissibleClass.Add(ClassKind.ElementDefinition);
            this.catEd3.PermissibleClass.Add(ClassKind.ElementDefinition);
            this.catEd4.PermissibleClass.Add(ClassKind.ElementDefinition);
            this.catRel.PermissibleClass.Add(ClassKind.BinaryRelationship);

            this.rule = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                SourceCategory = this.catEd1, TargetCategory = this.catEd2, RelationshipCategory = this.catRel, Name = "rel", ShortName = "rel"
            };

            this.sitedir.Model.Add(this.engineeringModelSetup);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup);
            this.engineeringModelSetup.RequiredRdl.Add(this.mrdl);
            this.engineeringModelSetup.Participant.Add(this.participant);
            this.engineeringModelSetup.ActiveDomain.Add(this.domain);

            this.srdl.DefinedCategory.Add(this.catEd1);
            this.srdl.DefinedCategory.Add(this.catEd2);
            this.srdl.DefinedCategory.Add(this.catEd3);
            this.srdl.DefinedCategory.Add(this.catEd4);
            this.srdl.DefinedCategory.Add(this.catRel);
            this.srdl.Rule.Add(this.rule);

            this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelSetup = this.engineeringModelSetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationSetup = this.iterationSetup
            };
            this.elementDef11 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "ed11", ShortName = "ed11", Owner = this.domain
            };
            this.elementDef12 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "ed12", ShortName = "ed12", Owner = this.domain
            };
            this.elementDef21 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "ed21", ShortName = "ed21", Owner = this.domain
            };
            this.elementDef22 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "ed22", ShortName = "ed22", Owner = this.domain
            };
            this.elementDef31 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "ed31", ShortName = "ed31", Owner = this.domain
            };

            this.elementDef11.Category.Add(this.catEd1);
            this.elementDef12.Category.Add(this.catEd3);
            this.elementDef21.Category.Add(this.catEd2);
            this.elementDef22.Category.Add(this.catEd4);

            this.elementDef31.Category.Add(this.catEd1);
            this.elementDef31.Category.Add(this.catEd2);

            this.model.Iteration.Add(this.iteration);
            this.iteration.Element.Add(this.elementDef11);
            this.iteration.Element.Add(this.elementDef12);
            this.iteration.Element.Add(this.elementDef21);
            this.iteration.Element.Add(this.elementDef22);
            this.iteration.Element.Add(this.elementDef31);

            this.assembler.Cache.TryAdd(new CacheKey(this.sitedir.Iid, null), new Lazy <Thing>(() => this.sitedir));
            this.assembler.Cache.TryAdd(new CacheKey(this.engineeringModelSetup.Iid, null), new Lazy <Thing>(() => this.engineeringModelSetup));
            this.assembler.Cache.TryAdd(new CacheKey(this.srdl.Iid, null), new Lazy <Thing>(() => this.srdl));
            this.assembler.Cache.TryAdd(new CacheKey(this.iterationSetup.Iid, null), new Lazy <Thing>(() => this.iterationSetup));
            this.assembler.Cache.TryAdd(new CacheKey(this.mrdl.Iid, null), new Lazy <Thing>(() => this.mrdl));
            this.assembler.Cache.TryAdd(new CacheKey(this.person.Iid, null), new Lazy <Thing>(() => this.person));
            this.assembler.Cache.TryAdd(new CacheKey(this.domain.Iid, null), new Lazy <Thing>(() => this.domain));
            this.assembler.Cache.TryAdd(new CacheKey(this.participant.Iid, null), new Lazy <Thing>(() => this.participant));
            this.assembler.Cache.TryAdd(new CacheKey(this.catEd1.Iid, null), new Lazy <Thing>(() => this.catEd1));
            this.assembler.Cache.TryAdd(new CacheKey(this.catEd2.Iid, null), new Lazy <Thing>(() => this.catEd2));
            this.assembler.Cache.TryAdd(new CacheKey(this.catEd3.Iid, null), new Lazy <Thing>(() => this.catEd3));
            this.assembler.Cache.TryAdd(new CacheKey(this.catEd4.Iid, null), new Lazy <Thing>(() => this.catEd4));
            this.assembler.Cache.TryAdd(new CacheKey(this.catRel.Iid, null), new Lazy <Thing>(() => this.catRel));
            this.assembler.Cache.TryAdd(new CacheKey(this.rule.Iid, null), new Lazy <Thing>(() => this.rule));

            this.assembler.Cache.TryAdd(new CacheKey(this.model.Iid, null), new Lazy <Thing>(() => this.model));
            this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.assembler.Cache.TryAdd(new CacheKey(this.elementDef11.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.elementDef11));
            this.assembler.Cache.TryAdd(new CacheKey(this.elementDef12.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.elementDef12));
            this.assembler.Cache.TryAdd(new CacheKey(this.elementDef21.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.elementDef21));
            this.assembler.Cache.TryAdd(new CacheKey(this.elementDef22.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.elementDef22));
            this.assembler.Cache.TryAdd(new CacheKey(this.elementDef31.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.elementDef31));

            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.session.Setup(x => x.Assembler).Returns(this.assembler);
            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.settings = new RelationshipMatrixPluginSettings();
            this.settings.PossibleClassKinds.Add(ClassKind.ElementDefinition);
            this.settings.PossibleClassKinds.Add(ClassKind.ElementUsage);
            this.pluginService.Setup(x => x.Read <RelationshipMatrixPluginSettings>()).Returns(this.settings);

            this.pluginService.Setup(x => x.Write(It.IsAny <RelationshipMatrixPluginSettings>()));
        }
Example #24
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.assembler.Cache.TryAdd(new CacheKey(this.sitedir.Iid, null), new Lazy <Thing>(() => this.sitedir));
            this.reqIf      = new ReqIF();
            this.reqIf.Lang = "en";
            var corecontent = new ReqIFContent();

            this.reqIf.CoreContent.Add(corecontent);
            this.stringDatadef = new DatatypeDefinitionString();
            this.spectype      = new RelationGroupType();
            this.attribute     = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.spectype.SpecAttributes.Add(this.attribute);

            corecontent.DataTypes.Add(this.stringDatadef);

            this.dialog = new RelationGroupTypeMappingDialogViewModel(new List <RelationGroupType> {
                this.spectype
            }, null, new Dictionary <DatatypeDefinition, DatatypeDefinitionMap> {
                { this.stringDatadef, new DatatypeDefinitionMap(this.stringDatadef, this.pt, null) }
            }, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, "en");
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }
        public void Setup()
        {
            var configurationFilePath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, "config.json");

            AppConfig.Load(configurationFilePath);

            this.authenticatedPerson = new AuthenticationPerson(Guid.NewGuid(), 1)
            {
                DefaultDomain = Guid.NewGuid()
            };
            this.credentials = new Credentials()
            {
                Person = this.authenticatedPerson
            };
            this.cdp4RequestContext = new Mock <ICdp4RequestContext>();
            this.cdp4RequestContext.Setup(x => x.AuthenticatedCredentials).Returns(this.credentials);
            this.requestUtils.Context = this.cdp4RequestContext.Object;

            this.iterationService             = new Mock <IIterationService>();
            this.iterationSetupService        = new Mock <IIterationSetupService>();
            this.engineeringModelService      = new Mock <IEngineeringModelService>();
            this.engineeringModelSetupService = new Mock <IEngineeringModelSetupService>();
            this.domainFileStoreService       = new Mock <IDomainFileStoreService>();
            this.participantService           = new Mock <IParticipantService>();
            this.optionService       = new Mock <IOptionService>();
            this.securityContext     = new Mock <ISecurityContext>();
            this.revisionService     = new Mock <IRevisionService>();
            this.personResolver      = new Mock <IPersonResolver>();
            this.permissionService   = new Mock <IPermissionService>();
            this.engineeringModelDao = new Mock <IEngineeringModelDao>();
            this.npgsqlTransaction   = null;

            this.modelCreatorManager = new ModelCreatorManager();
            this.modelCreatorManager.RevisionService = this.revisionService.Object;

            this.engineeringModelSetupSideEffect = new EngineeringModelSetupSideEffect
            {
                EngineeringModelService      = this.engineeringModelService.Object,
                EngineeringModelSetupService = this.engineeringModelSetupService.Object,
                IterationService             = this.iterationService.Object,
                IterationSetupService        = this.iterationSetupService.Object,
                ParticipantService           = this.participantService.Object,
                DomainFileStoreService       = this.domainFileStoreService.Object,
                OptionService       = this.optionService.Object,
                RequestUtils        = this.requestUtils,
                ModelCreatorManager = this.modelCreatorManager,
                PersonResolver      = this.personResolver.Object,
                PermissionService   = this.permissionService.Object,
                RevisionService     = this.revisionService.Object,
                EngineeringModelDao = this.engineeringModelDao.Object
            };

            this.siteDirectory         = new SiteDirectory(Guid.NewGuid(), 1);
            this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), 1);
            var domainOfExpertise  = new DomainOfExpertise(Guid.NewGuid(), 1);
            var domainOfExpertise1 = new DomainOfExpertise(Guid.NewGuid(), 1);
            var domainFileStore    = new DomainFileStore(Guid.NewGuid(), 1);

            domainFileStore.Owner = domainOfExpertise.Iid;
            var domainFileStore1 = new DomainFileStore(Guid.NewGuid(), 1);

            domainFileStore1.Owner = domainOfExpertise1.Iid;
            var option = new Option(Guid.NewGuid(), 1)
            {
                Name      = "Option 1",
                ShortName = "optioin_1"
            };

            this.engineeringModelSetup.ActiveDomain.Add(domainOfExpertise.Iid);
            var engineeringModel = new EngineeringModel(this.engineeringModelSetup.EngineeringModelIid, 1);
            var iteration        = new Iteration(Guid.NewGuid(), 1);

            iteration.DomainFileStore.Add(domainFileStore.Iid);

            var orderedOption = new OrderedItem
            {
                K = 1,
                V = option.Iid
            };

            iteration.Option.Add(orderedOption);

            var iterationSetup = new IterationSetup(Guid.NewGuid(), 1);

            this.engineeringModelSetup.IterationSetup.Add(iterationSetup.Iid);

            var participant = new Participant(Guid.NewGuid(), 1);

            this.engineeringModelSetup.Participant.Add(participant.Iid);

            engineeringModel.Iteration.Add(iteration.Iid);
            iterationSetup.IterationIid = iteration.Iid;
            this.siteDirectory.Model.Add(this.engineeringModelSetup.Iid);
            this.siteDirectory.DefaultParticipantRole = Guid.NewGuid();

            this.engineeringModelService.Setup(x => x.CreateConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <EngineeringModel>(), It.IsAny <Thing>(), -1)).Returns(true);
            this.engineeringModelService.Setup(x => x.DeleteConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <EngineeringModel>(), null)).Returns(true);
            this.engineeringModelService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <IEnumerable <Guid> >(), this.securityContext.Object)).Returns(new[] { engineeringModel });

            this.engineeringModelSetupService.Setup(x => x.UpdateConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <EngineeringModelSetup>(), It.IsAny <Thing>())).Returns(true);

            this.iterationService.Setup(x => x.CreateConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <Iteration>(), It.IsAny <EngineeringModel>(), -1)).Returns(true);
            this.iterationService.Setup(
                x =>
                x.GetShallow(
                    It.IsAny <NpgsqlTransaction>(),
                    It.IsAny <string>(),
                    It.IsAny <IEnumerable <Guid> >(),
                    this.securityContext.Object)).Returns(new[] { iteration });
            this.iterationSetupService.Setup(x => x.CreateConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <IterationSetup>(), It.IsAny <EngineeringModelSetup>(), -1)).Returns(true);
            this.iterationSetupService.Setup(
                x =>
                x.GetShallow(
                    It.IsAny <NpgsqlTransaction>(),
                    It.IsAny <string>(),
                    It.IsAny <IEnumerable <Guid> >(),
                    this.securityContext.Object)).Returns(new[] { iterationSetup });

            this.participantService.Setup(x => x.CreateConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <Participant>(), It.IsAny <EngineeringModelSetup>(), -1)).Returns(true);
            this.participantService.Setup(
                x =>
                x.GetShallow(
                    It.IsAny <NpgsqlTransaction>(),
                    It.IsAny <string>(),
                    It.IsAny <IEnumerable <Guid> >(),
                    this.securityContext.Object)).Returns(new[] { participant });

            this.domainFileStoreService.Setup(x => x.CreateConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <DomainFileStore>(), It.IsAny <Iteration>(), -1)).Returns(true);
            this.domainFileStoreService.Setup(
                x =>
                x.GetShallow(
                    It.IsAny <NpgsqlTransaction>(),
                    It.IsAny <string>(),
                    It.IsAny <IEnumerable <Guid> >(),
                    this.securityContext.Object)).Returns(new[] { domainFileStore });

            this.domainFileStoreService.Setup(x => x.DeleteConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <DomainFileStore>(), It.IsAny <Iteration>())).Returns(true);

            this.optionService.Setup(x => x.CreateConcept(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <Option>(), It.IsAny <Iteration>(), -1)).Returns(true);
            this.optionService.Setup(x => x.GetShallow(
                                         It.IsAny <NpgsqlTransaction>(),
                                         It.IsAny <string>(),
                                         It.IsAny <IEnumerable <Guid> >(),
                                         this.securityContext.Object)).Returns(new[] { option });

            this.revisionService.Setup(
                x => x.SaveRevisions(
                    It.IsAny <NpgsqlTransaction>(),
                    It.IsAny <string>(),
                    It.IsAny <Guid>(),
                    It.IsAny <int>())).Returns(new List <Thing>());

            this.engineeringModelDao.Setup(x => x.GetNextIterationNumber(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>())).Returns(1);
        }
        public void VerifyCopyElementDefWorks()
        {
            var modelSetupService = new Mock <IEngineeringModelSetupService>();
            var modelSetup        = new EngineeringModelSetup(Guid.NewGuid(), 0);

            modelSetupService.Setup(x => x.GetEngineeringModelSetup(It.IsAny <NpgsqlTransaction>(), It.IsAny <Guid>())).Returns(modelSetup);

            this.copySourceDtos = new List <Thing>();

            var boolParamTypeId = Guid.NewGuid();
            var mrdl            = new ModelReferenceDataLibrary(Guid.NewGuid(), 1);

            mrdl.ParameterType.Add(boolParamTypeId);

            var sourceIteration   = new Iteration(Guid.NewGuid(), 1);
            var sourceElementDef1 = new ElementDefinition(Guid.NewGuid(), 1);
            var sourceElementDef2 = new ElementDefinition(Guid.NewGuid(), 1);
            var sourceUsage1      = new ElementUsage(Guid.NewGuid(), 1)
            {
                ElementDefinition = sourceElementDef2.Iid
            };

            sourceElementDef1.ContainedElement.Add(sourceUsage1.Iid);
            sourceIteration.Element.Add(sourceElementDef1.Iid);
            sourceIteration.Element.Add(sourceElementDef2.Iid);

            var parameter1 = new Parameter(Guid.NewGuid(), 1)
            {
                ParameterType = boolParamTypeId
            };
            var pvs1 = new ParameterValueSet(Guid.NewGuid(), 1)
            {
                Manual      = new ValueArray <string>(new[] { "true" }),
                Computed    = new ValueArray <string>(new[] { "-" }),
                Reference   = new ValueArray <string>(new[] { "-" }),
                Published   = new ValueArray <string>(new[] { "-" }),
                ValueSwitch = ParameterSwitchKind.MANUAL
            };

            var parameter2 = new Parameter(Guid.NewGuid(), 1)
            {
                ParameterType = boolParamTypeId
            };
            var pvs2 = new ParameterValueSet(Guid.NewGuid(), 1)
            {
                Manual      = new ValueArray <string>(new[] { "true" }),
                Computed    = new ValueArray <string>(new[] { "-" }),
                Reference   = new ValueArray <string>(new[] { "-" }),
                Published   = new ValueArray <string>(new[] { "-" }),
                ValueSwitch = ParameterSwitchKind.MANUAL
            };

            parameter1.ValueSet.Add(pvs1.Iid);
            sourceElementDef1.Parameter.Add(parameter1.Iid);
            parameter2.ValueSet.Add(pvs2.Iid);
            sourceElementDef2.Parameter.Add(parameter2.Iid);

            var override2 = new ParameterOverride(Guid.NewGuid(), 1);

            override2.Parameter = parameter2.Iid;
            var ovs = new ParameterOverrideValueSet(Guid.NewGuid(), 1)
            {
                ParameterValueSet = pvs2.Iid
            };

            override2.ValueSet.Add(ovs.Iid);
            sourceUsage1.ParameterOverride.Add(override2.Iid);

            this.copySourceDtos.Add(sourceIteration);
            this.copySourceDtos.Add(sourceElementDef1);
            this.copySourceDtos.Add(sourceElementDef2);
            this.copySourceDtos.Add(sourceUsage1);
            this.copySourceDtos.Add(parameter1);
            this.copySourceDtos.Add(pvs1);
            this.copySourceDtos.Add(parameter2);
            this.copySourceDtos.Add(pvs2);
            this.copySourceDtos.Add(override2);
            this.copySourceDtos.Add(ovs);

            var targetIteration = new Iteration(Guid.NewGuid(), 1);

            this.serviceProvider.Setup(x => x.MapToReadService(It.IsAny <string>())).Returns <string>(x => new TestSourceService(this.copySourceDtos, x));
            this.serviceProvider.Setup(x => x.MapToReadService(It.Is <string>(t => t == ClassKind.ModelReferenceDataLibrary.ToString())))
            .Returns <string>(x => new TestSourceService(new List <Thing> {
                mrdl
            }, x));

            this.serviceProvider.Setup(x => x.MapToReadService(It.Is <string>(t => t == ClassKind.Iteration.ToString())))
            .Returns <string>(x => new TestSourceService(new List <Thing> {
                sourceIteration, targetIteration
            }, x));

            var customOperationSideEffectProcessor = new Mock <IOperationSideEffectProcessor>();

            customOperationSideEffectProcessor.Setup(x => x.BeforeCreate(It.IsAny <Thing>(), It.IsAny <Thing>(), It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <ISecurityContext>())).
            Returns(true);

            var paramSubscriptionService = new ParameterSubscriptionService
            {
                ParameterSubscriptionDao = new Mock <IParameterSubscriptionDao>().Object,
                PermissionService        = this.permissionService.Object,
            };

            var parameterContextProvider = new OldParameterContextProvider
            {
                ParameterValueSetService = new TestSourceService(this.copySourceDtos, ClassKind.ParameterValueSet.ToString())
            };

            var paramGroupService = new ParameterGroupService
            {
                PermissionService = this.permissionService.Object,

                TransactionManager = this.transactionManager.Object,
                ParameterGroupDao  = new Mock <IParameterGroupDao>().Object
            };

            var valueSetService = new Mock <IParameterValueSetService>();

            valueSetService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <IEnumerable <Guid> >(), It.IsAny <ISecurityContext>()))
            .Returns <NpgsqlTransaction, string, IEnumerable <Guid>, ISecurityContext>((a, b, c, d) =>
            {
                var list = new List <ParameterValueSet>();
                foreach (var guid in c)
                {
                    var vs = new ParameterValueSet(guid, 1)
                    {
                        Manual    = new ValueArray <string>(new [] { "-" }),
                        Computed  = new ValueArray <string>(new [] { "-" }),
                        Reference = new ValueArray <string>(new [] { "-" }),
                        Published = new ValueArray <string>(new [] { "-" })
                    };

                    list.Add(vs);
                }

                return(list);
            });

            var overrideValueSetService = new Mock <IParameterOverrideValueSetService>();

            overrideValueSetService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <IEnumerable <Guid> >(), It.IsAny <ISecurityContext>()))
            .Returns <NpgsqlTransaction, string, IEnumerable <Guid>, ISecurityContext>((a, b, c, d) =>
            {
                var list = new List <ParameterOverrideValueSet>();
                foreach (var guid in c)
                {
                    var vs = new ParameterOverrideValueSet(guid, 1)
                    {
                        Manual    = new ValueArray <string>(new[] { "-" }),
                        Computed  = new ValueArray <string>(new[] { "-" }),
                        Reference = new ValueArray <string>(new[] { "-" }),
                        Published = new ValueArray <string>(new[] { "-" })
                    };

                    list.Add(vs);
                }

                return(list);
            });

            var paramDao     = new TestParameterDao();
            var paramService = new ParameterService
            {
                PermissionService            = this.permissionService.Object,
                ParameterDao                 = paramDao,
                OperationSideEffectProcessor = customOperationSideEffectProcessor.Object,
                TransactionManager           = this.transactionManager.Object,
                OldParameterContextProvider  = parameterContextProvider,
                ParameterSubscriptionService = paramSubscriptionService,
                ParameterValueSetService     = valueSetService.Object
            };

            var paramOverrideDao = new TestParameterOverrideDao();

            var paramOverrideService = new ParameterOverrideService
            {
                PermissionService = this.permissionService.Object,

                ParameterOverrideDao             = paramOverrideDao,
                TransactionManager               = this.transactionManager.Object,
                OperationSideEffectProcessor     = customOperationSideEffectProcessor.Object,
                ParameterSubscriptionService     = paramSubscriptionService,
                ParameterOverrideValueSetService = overrideValueSetService.Object
            };

            var usageDao     = new Mock <IElementUsageDao>();
            var usageService = new ElementUsageService
            {
                PermissionService = this.permissionService.Object,

                ParameterOverrideService     = paramOverrideService,
                ElementUsageDao              = usageDao.Object,
                TransactionManager           = this.transactionManager.Object,
                OperationSideEffectProcessor = customOperationSideEffectProcessor.Object
            };

            var edDao     = new TestElementDefinitionDao();
            var edService = new ElementDefinitionService
            {
                PermissionService = this.permissionService.Object,

                ElementDefinitionDao         = edDao,
                ElementUsageService          = usageService,
                ParameterService             = paramService,
                TransactionManager           = this.transactionManager.Object,
                OperationSideEffectProcessor = customOperationSideEffectProcessor.Object,
                ParameterGroupService        = paramGroupService
            };

            this.serviceProvider.Setup(x => x.MapToPersitableService(ClassKind.ElementDefinition.ToString())).Returns(edService);
            this.serviceProvider.Setup(x => x.MapToPersitableService(ClassKind.ElementUsage.ToString())).Returns(usageService);
            this.serviceProvider.Setup(x => x.MapToPersitableService(ClassKind.Parameter.ToString())).Returns(paramService);
            this.serviceProvider.Setup(x => x.MapToPersitableService(ClassKind.ParameterOverride.ToString())).Returns(paramOverrideService);
            this.serviceProvider.Setup(x => x.MapToPersitableService(ClassKind.ParameterSubscription.ToString())).Returns(paramSubscriptionService);
            this.serviceProvider.Setup(x => x.MapToPersitableService(ClassKind.ParameterGroup.ToString())).Returns(paramGroupService);

            var postOperation = new CdpPostOperation();
            var copyinfo      = new CopyInfo
            {
                ActiveOwner = Guid.NewGuid(),
                Options     = new CopyInfoOptions
                {
                    CopyKind   = CopyKind.Deep,
                    KeepOwner  = true,
                    KeepValues = true
                },
                Source = new CopySource
                {
                    IterationId = sourceIteration.Iid,
                    Thing       = new CopyReference
                    {
                        Iid       = sourceElementDef1.Iid,
                        ClassKind = ClassKind.ElementDefinition
                    },
                    TopContainer = new CopyReference
                    {
                        Iid       = Guid.NewGuid(),
                        ClassKind = ClassKind.EngineeringModel
                    }
                },
                Target = new CopyTarget
                {
                    IterationId = targetIteration.Iid,
                    Container   = new CopyReference
                    {
                        Iid       = targetIteration.Iid,
                        ClassKind = ClassKind.Iteration
                    },
                    TopContainer = new CopyReference
                    {
                        Iid       = Guid.NewGuid(),
                        ClassKind = ClassKind.EngineeringModel
                    }
                }
            };

            postOperation.Copy.Add(copyinfo);

            this.serviceProvider.Setup(x => x.MapToReadService(ClassKind.EngineeringModelSetup.ToString())).Returns(modelSetupService.Object);
            this.operationProcessor.Process(postOperation, null, $"Iteration_{targetIteration.Iid.ToString().Replace("-", "_")}", null);

            Assert.AreEqual(2, edDao.WrittenThingCount);
            Assert.AreEqual(2, paramDao.WrittenThingCount);
            Assert.AreEqual(1, paramOverrideDao.WrittenThingCount);
            usageDao.Verify(x => x.Write(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), It.IsAny <ElementUsage>(), It.IsAny <Thing>()), Times.Once);
        }
Example #27
0
 /// <summary>
 /// Copy the <paramref name="sourceThing"/> into the target <paramref name="partition"/>
 /// </summary>
 /// <param name="transaction">The current transaction</param>
 /// <param name="partition">The current partition</param>
 /// <param name="sourceThing">The source <see cref="Thing"/> to copy</param>
 /// <param name="targetContainer">The target container <see cref="Thing"/></param>
 /// <param name="allSourceThings">All source <see cref="Thing"/>s in the current copy operation</param>
 /// <param name="copyinfo">The <see cref="CopyInfo"/></param>
 /// <param name="sourceToCopyMap">A dictionary mapping identifiers of original to copy</param>
 /// <param name="rdls">The <see cref="ReferenceDataLibrary"/></param>
 /// <param name="targetEngineeringModelSetup">The target <see cref="EngineeringModelSetup"/></param>
 /// <param name="securityContext">The <see cref="ISecurityContext"/></param>
 public virtual void Copy(NpgsqlTransaction transaction, string partition, Thing sourceThing, Thing targetContainer, IReadOnlyList <Thing> allSourceThings, CopyInfo copyinfo,
                          Dictionary <Guid, Guid> sourceToCopyMap, IReadOnlyList <ReferenceDataLibrary> rdls, EngineeringModelSetup targetEngineeringModelSetup, ISecurityContext securityContext)
 {
 }
        public void Setup()
        {
            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.cache, null);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, null);
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, null);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, null)
            {
                RequiredRdl = this.srdl
            };
            this.parameterType = new BooleanParameterType(Guid.NewGuid(), this.cache, null)
            {
                Name = "boolean", ShortName = "bool"
            };
            this.category = new Category(Guid.NewGuid(), this.cache, null)
            {
                Name = "cat", ShortName = "cat",
            };
            this.rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, null)
            {
                Category = this.category, ShortName = "rule", Name = "rule"
            };
            this.rule.ParameterType.Add(this.parameterType);

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

            this.srdl.ParameterType.Add(this.parameterType);
            this.srdl.DefinedCategory.Add(this.category);
            this.srdl.Rule.Add(this.rule);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, null)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, null)
            {
                IterationSetup = this.iterationsetup
            };

            this.relation1 = new BinaryRelationship(Guid.NewGuid(), this.cache, null);
            this.relation2 = new BinaryRelationship(Guid.NewGuid(), this.cache, null);
            this.spec1     = new RequirementsSpecification(Guid.NewGuid(), this.cache, null)
            {
                Name = "spec1", ShortName = "spec1"
            };
            this.spec2 = new RequirementsSpecification(Guid.NewGuid(), this.cache, null)
            {
                Name = "spec2", ShortName = "spec2"
            };

            this.gr1 = new RequirementsGroup(Guid.NewGuid(), this.cache, null)
            {
                Name = "gr1", ShortName = "gr1"
            };
            this.gr2 = new RequirementsGroup(Guid.NewGuid(), this.cache, null)
            {
                Name = "gr2", ShortName = "gr2"
            };

            this.req1 = new Requirement(Guid.NewGuid(), this.cache, null)
            {
                Name = "r1", ShortName = "r1"
            };
            this.req2 = new Requirement(Guid.NewGuid(), this.cache, null)
            {
                Name = "r2", ShortName = "r2"
            };

            this.def1 = new ElementDefinition(Guid.NewGuid(), this.cache, null)
            {
                Name = "d1", ShortName = "d1"
            };
            this.def2 = new ElementDefinition(Guid.NewGuid(), this.cache, null)
            {
                Name = "d2", ShortName = "d2"
            };

            this.model.Iteration.Add(this.iteration);
            this.iteration.Relationship.Add(this.relation1);
            this.iteration.Relationship.Add(this.relation2);
            this.iteration.RequirementsSpecification.Add(this.spec1);
            this.iteration.RequirementsSpecification.Add(this.spec2);

            this.spec1.Group.Add(this.gr1);
            this.spec1.Group.Add(this.gr2);
            this.spec1.Requirement.Add(this.req1);
            this.spec1.Requirement.Add(this.req2);

            this.iteration.Element.Add(this.def1);
            this.iteration.Element.Add(this.def2);

            this.relation1.Category.Add(this.category);
            this.relation2.Category.Add(this.category);
            this.spec1.Category.Add(this.category);
            this.spec2.Category.Add(this.category);
            this.req1.Category.Add(this.category);
            this.req2.Category.Add(this.category);
            this.gr1.Category.Add(this.category);
            this.gr2.Category.Add(this.category);
            this.def1.Category.Add(this.category);
            this.def2.Category.Add(this.category);

            this.relation1.ParameterValue.Add(new RelationshipParameterValue(Guid.NewGuid(), this.cache, null)
            {
                ParameterType = this.parameterType
            });
            this.spec1.ParameterValue.Add(new RequirementsContainerParameterValue(Guid.NewGuid(), this.cache, null)
            {
                ParameterType = this.parameterType
            });
            this.req1.ParameterValue.Add(new SimpleParameterValue(Guid.NewGuid(), this.cache, null)
            {
                ParameterType = this.parameterType
            });
            this.def1.Parameter.Add(new Parameter(Guid.NewGuid(), this.cache, null)
            {
                ParameterType = this.parameterType
            });
            this.gr1.ParameterValue.Add(new RequirementsContainerParameterValue(Guid.NewGuid(), this.cache, null)
            {
                ParameterType = this.parameterType
            });
        }
        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.domain1    = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);
            this.srdl       = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl       = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.cat1 = new Category(Guid.NewGuid(), this.cache, this.uri);
            this.cat1.PermissibleClass.Add(ClassKind.ElementUsage);
            this.cat2 = new Category(Guid.NewGuid(), this.cache, this.uri);

            this.siteDir.SiteReferenceDataLibrary.Add(this.srdl);
            this.siteDir.Model.Add(this.modelsetup);
            this.siteDir.Domain.Add(this.domain1);
            this.modelsetup.RequiredRdl.Add(this.mrdl);
            this.mrdl.DefinedCategory.Add(this.cat2);
            this.srdl.DefinedCategory.Add(this.cat1);
            this.modelsetup.ActiveDomain.Add(this.domain1);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration   = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.option      = new Option(Guid.NewGuid(), this.cache, this.uri);
            this.definition1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);
            this.definition2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);

            this.usage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ElementDefinition = this.definition2
            };

            this.model.Iteration.Add(this.iteration);
            this.iteration.Option.Add(this.option);
            this.iteration.Element.Add(this.definition1);
            this.iteration.Element.Add(this.definition2);

            this.definition1.ContainedElement.Add(this.usage);

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

            this.usageClone       = this.usage.Clone(false);
            this.definition1Clone = this.definition1.Clone(false);

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

            this.thingTransaction = new ThingTransaction(transactionContext, this.definition1Clone);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);

            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());
        }
Example #30
0
        public void Setup()
        {
            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(), null, this.uri);
            this.state1    = new PossibleFiniteState(Guid.NewGuid(), null, this.uri)
            {
                Name = "state1"
            };
            this.state2 = new PossibleFiniteState(Guid.NewGuid(), null, this.uri)
            {
                Name = "state2"
            };

            this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), null, 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(), null, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    this.state1
                },
                Kind = ActualFiniteStateKind.MANDATORY
            };

            this.actualState2 = new ActualFiniteState(Guid.NewGuid(), null, 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(), null, this.uri)
            {
                Name = "option1"
            };
            this.option2 = new Option(Guid.NewGuid(), null, this.uri)
            {
                Name = "option2"
            };

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

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

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

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

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

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

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

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

            this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option1, this.stateList.ActualState.First()));
            this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option1, this.stateList.ActualState.Last()));
            this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option2, this.stateList.ActualState.First()));
            this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option2, this.stateList.ActualState.Last()));

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, this.uri)
            {
                Owner = this.activeDomain
            };
            this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), null, this.uri);
            this.elementUsage1 = new ElementUsage(Guid.NewGuid(), null, 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(), null, 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(), null, this.uri);
            this.model.Iteration.Add(this.iteration);

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

            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);

            this.assembler = new Assembler(this.uri);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());
        }