/// <summary>
 /// Set the iteration context to a specific iteration.
 /// </summary>
 /// <param name="transaction">
 /// The current transaction to the database.
 /// </param>
 /// <param name="partition">
 /// The database partition (schema) where the requested resource is stored.
 /// </param>
 /// <param name="iterationId">
 /// The iteration id.
 /// </param>
 public void SetIterationContext(NpgsqlTransaction transaction, string partition, Guid iterationId)
 {
     // use default (non-iteration-tagged) temporal context to retrieve iterationsetup
     this.SetDefaultContext(transaction);
     this.IterationSetup = this.GetIterationContext(transaction, iterationId);
     this.SetIterationContext(transaction, partition);
 }
        private void BuildIterationTestData()
        {
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);

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

            var iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationIid = this.iteration.Iid, IterationNumber = 1
            };
            var modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "ModelSetup",
                EngineeringModelIid = model.Iid
            };

            modelSetup.Participant.Add(this.participant);

            modelSetup.Container = this.session.Object.RetrieveSiteDirectory();

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

            this.iteration.IterationSetup = iterationSetup;
            model.EngineeringModelSetup   = modelSetup;

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
        }
Beispiel #3
0
        public void VerifyThatRequiredRdlRdlsReturnsExpectedResult()
        {
            var genericRdl  = new SiteReferenceDataLibrary();
            var familyofRdl = new SiteReferenceDataLibrary();

            familyofRdl.RequiredRdl = genericRdl;

            var modelrdl = new ModelReferenceDataLibrary();

            modelrdl.RequiredRdl = familyofRdl;

            var iteration        = new Iteration();
            var engineeringModel = new EngineeringModel();

            engineeringModel.Iteration.Add(iteration);

            var engineeringModelSetup = new EngineeringModelSetup();
            var iterationSetup        = new IterationSetup();

            engineeringModelSetup.RequiredRdl.Add(modelrdl);
            engineeringModelSetup.IterationSetup.Add(iterationSetup);

            iteration.IterationSetup = iterationSetup;

            var requiredRdls = iteration.RequiredRdls;

            CollectionAssert.Contains(requiredRdls, genericRdl);
            CollectionAssert.Contains(requiredRdls, familyofRdl);
            CollectionAssert.Contains(requiredRdls, modelrdl);

            Assert.AreEqual(3, requiredRdls.Count());
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductTreeViewModel"/> class
        /// </summary>
        /// <param name="option">The <see cref="Option"/> of which this browser is of</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>
        /// <param name="pluginSettingsService">
        /// The <see cref="IPluginSettingsService"/> used to read and write plugin setting files.
        /// </param>
        public ProductTreeViewModel(Option option, ISession session, IThingDialogNavigationService thingDialogNavigationService, IPanelNavigationService panelNavigationService, IDialogNavigationService dialogNavigationService, IPluginSettingsService pluginSettingsService)
            : base(option, session, thingDialogNavigationService, panelNavigationService, dialogNavigationService, pluginSettingsService)
        {
            this.Caption = $"{PanelCaption}, {this.Thing.Name}";
            this.ToolTip = $"{this.Thing.Name}\n{this.Thing.IDalUri}\n{this.Session.ActivePerson.Name}";

            this.TopElement = new DisposableReactiveList <ElementDefinitionRowViewModel>();
            var model = (EngineeringModel)this.Thing.TopContainer;

            this.modelSetup = model.EngineeringModelSetup;

            var iteration = (Iteration)this.Thing.Container;

            this.iterationSetup = iteration.IterationSetup;

            this.ActiveParticipant = this.modelSetup.Participant.Single(x => x.Person == this.Session.ActivePerson);

            var iterationSubscription = CDPMessageBus.Current.Listen <ObjectChangedEvent>(iteration)
                                        .Where(
                objectChange =>
                (objectChange.EventKind == EventKind.Updated) &&
                (objectChange.ChangedThing.RevisionNumber > this.RevisionNumber))
                                        .Select(x => x.ChangedThing as Iteration)
                                        .ObserveOn(RxApp.MainThreadScheduler)
                                        .Subscribe(this.SetTopElement);

            this.Disposables.Add(iterationSubscription);

            this.AddSubscriptions();

            this.SetTopElement(iteration);

            this.UpdateProperties();
        }
Beispiel #5
0
        public void Setup()
        {
            var ensurePackSchemeIsKnown = System.IO.Packaging.PackUriHelper.UriSchemePack;

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

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

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

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

            this.parameterType1 = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "pt1"
            };
            this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.parameterType1, Owner = this.domain
            };
            this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };
            this.state1   = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.valueset = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri);
            this.stateList.ActualState.Add(this.state1);
            this.elementdef1.Parameter.Add(this.parameter1);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());

            this.cache.TryAdd(new CacheKey(this.parameter1.Iid, null), new Lazy <Thing>(() => this.parameter1));
            this.converter = new ProductTreeIconUriConverter();
        }
Beispiel #6
0
        public void SetUp()
        {
            this.optionService = new Mock <IOptionService>();
            this.engineeringModelSetupService = new Mock <IEngineeringModelSetupService>();
            this.iterationService             = new Mock <IIterationService>();
            this.iterationSetupService        = new Mock <IIterationSetupService>();
            this.securityContext         = new Mock <ISecurityContext>();
            this.engineeringModelService = new Mock <IEngineeringModelService>();
            this.requestUtils            = new Mock <IRequestUtils>();
            this.npgsqlTransaction       = null;

            this.option1 = new Option(Guid.NewGuid(), 0);
            this.option2 = new Option(Guid.NewGuid(), 0);
            this.options = new List <Option>();
            this.optionService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(),
                                                       It.IsAny <IEnumerable <Guid> >(), It.IsAny <ISecurityContext>())).Returns(options);

            this.iterationSetup = new IterationSetup
            {
                Iid = Guid.NewGuid()
            };

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

            this.iteration.DefaultOption = this.option1.Iid;

            this.iterationSetup.IterationIid = this.iteration.Iid;

            this.updatedIteration = this.iteration.DeepClone <Iteration>();

            this.engineeringModelSetup = new EngineeringModelSetup
            {
                Iid            = Guid.NewGuid(),
                IterationSetup = new List <Guid> {
                    this.iterationSetup.Iid
                },
            };

            this.engineeringModel = new EngineeringModel
            {
                Iid = Guid.NewGuid(),
                EngineeringModelSetup = this.engineeringModelSetup.Iid
            };
            this.engineeringModelSetup.EngineeringModelIid = this.engineeringModel.Iid;

            this.optionSideEffect = new OptionSideEffect
            {
                OptionService = this.optionService.Object,
                EngineeringModelSetupService = this.engineeringModelSetupService.Object,
                EngineeringModelService      = this.engineeringModelService.Object,
                IterationService             = this.iterationService.Object,
                IterationSetupService        = this.iterationSetupService.Object,
                RequestUtils = this.requestUtils.Object
            };
        }
Beispiel #7
0
        public void SetUp()
        {
            var ensurePackSchemeIsKnown = System.IO.Packaging.PackUriHelper.UriSchemePack;

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

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

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

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

            this.parameterType = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "pt1"
            };
            this.parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.parameterType, Owner = this.domain
            };
            this.converter = new ProductTreeIconUriConverter();
            this.elementdef.Parameter.Add(this.parameter);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());

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

            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

            this.nestedElementTreeService = new Mock <INestedElementTreeService>();
            this.serviceLocator.Setup(x => x.GetInstance <INestedElementTreeService>()).Returns(this.nestedElementTreeService.Object);
        }
Beispiel #8
0
        public void Setup()
        {
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

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

            this.iterationSetupListBoxItem = new IterationSetupListBoxItem(this.iteration);
        }
        /// <summary>
        /// Add the <see cref="IterationSetup" /> to the contained <see cref="SwitchDomainIterationSetupRowViewModel" />
        /// </summary>
        /// <param name="iterationSetup">
        /// the <see cref="IterationSetup" /> object that are to be added
        /// </param>
        private void AddIteration(IterationSetup iterationSetup)
        {
            var activeParticipant = this.Thing.Participant.Single(x => x.Person == this.Session.ActivePerson);

            var row = new SwitchDomainIterationSetupRowViewModel(iterationSetup, activeParticipant, this.Session);

            this.IterationSetupRowViewModels.Add(row);
        }
Beispiel #10
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.session   = new Mock <ISession>();
            this.assembler = new Assembler(this.uri);
            this.cache     = this.assembler.Cache;

            this.permissionService = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);

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

            this.person = new Person(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "test"
            };
            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                SelectedDomain = null, Person = this.person
            };
            this.model      = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.iteration      = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec        = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.reqGroup       = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri);

            this.modelSetup.IterationSetup.Add(this.iterationSetup);
            this.modelSetup.Participant.Add(this.participant);

            this.panelNavigation  = new Mock <IPanelNavigationService>();
            this.dialogNavigation = new Mock <IThingDialogNavigationService>();

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

            this.iteration.RequirementsSpecification.Add(this.reqSpec);
            this.iteration.IterationSetup    = this.iterationSetup;
            this.model.EngineeringModelSetup = this.modelSetup;
            this.model.Iteration.Add(this.iteration);
            this.reqSpec.Group.Add(this.reqGroup);

            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString());
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(null, this.participant) }
            });
        }
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            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.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

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

            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.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
        }
Beispiel #12
0
        /// <summary>
        /// Remove the <see cref="IterationSetup"/>
        /// </summary>
        /// <param name="iteration">
        /// the <see cref="IterationSetup"/> object to remove
        /// </param>
        private void RemoveIteration(IterationSetup iteration)
        {
            var row = this.iterationSetupFolderRow.ContainedRows.SingleOrDefault(r => r.Thing == iteration);

            if (row != null)
            {
                this.iterationSetupFolderRow.ContainedRows.RemoveAndDispose(row);
            }
        }
Beispiel #13
0
        public void Setup()
        {
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();

            this.uri     = new Uri("http://test.com");
            this.siteDir = new SiteDirectory(Guid.NewGuid(), null, this.uri);
            this.domain  = new DomainOfExpertise(Guid.NewGuid(), null, this.uri);
            this.siteDir.Domain.Add(this.domain);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri);
            this.modelsetup.ActiveDomain.Add(this.domain);

            this.reqSpec  = new RequirementsSpecification(Guid.NewGuid(), null, this.uri);
            this.reqGroup = new RequirementsGroup(Guid.NewGuid(), null, this.uri);

            this.engineeringModel = new EngineeringModel(Guid.NewGuid(), null, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), null, this.uri);
            this.requirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), null, this.uri);
            this.engineeringModelSetup     = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri);
            this.iterationSetup            = new IterationSetup(Guid.NewGuid(), null, this.uri);
            this.iteration.IterationSetup  = this.iterationSetup;

            var person = new Person(Guid.NewGuid(), null, this.uri);

            this.domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), null, this.uri)
            {
                Name = "test"
            };
            person.DefaultDomain = this.domainOfExpertise;

            this.engineeringModelSetup.ActiveDomain.Add(this.domainOfExpertise);
            this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.ActivePerson).Returns(person);
            this.siteDir.Domain.Add(this.domainOfExpertise);

            this.engineeringModel.Iteration.Add(this.iteration);
            this.iteration.RequirementsSpecification.Add(this.requirementsSpecification);
            this.iteration.RequirementsSpecification.Add(this.reqSpec);
            this.requirementsSpecification.Group.Add(this.reqGroup);

            this.engineeringModel.EngineeringModelSetup = this.engineeringModelSetup;

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

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

            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.session = new Mock <ISession>()
            {
                Name = "http://www.rheagroup.com/"
            };
            this.permissionService = new Mock <IPermissionService>();

            this.siteDirectory = new SiteDirectory(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"))
            {
                Name = "TestSiteDir"
            };
            this.model1 = new EngineeringModelSetup(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"))
            {
                Name = "model1"
            };
            this.model2 = new EngineeringModelSetup(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"))
            {
                Name = "model2"
            };
            this.iteration11          = new IterationSetup(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"));
            this.iteration21          = new IterationSetup(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"));
            this.frozenOnDate         = "1992-01-12 12:12:30";
            this.iteration21.FrozenOn = DateTime.Parse(this.frozenOnDate);

            this.iteration22 = new IterationSetup(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"));

            this.person = new Person(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"))
            {
                GivenName = "testPerson"
            };
            this.domain = new DomainOfExpertise(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"))
            {
                Name = "domaintest"
            };

            this.person.DefaultDomain = this.domain;
            this.model1.Participant.Add(new Participant(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"))
            {
                Person = this.person,
                Domain = { this.domain }
            });

            this.model1.IterationSetup.Add(this.iteration11);
            this.model2.IterationSetup.Add(this.iteration21);
            this.model2.IterationSetup.Add(this.iteration22);
            this.siteDirectory.Model.Add(this.model1);
            this.siteDirectory.Model.Add(this.model2);
            this.siteDirectory.Person.Add(this.person);
            this.model2.Participant.Add(new Participant(Guid.NewGuid(), null, new Uri("http://www.rheagroup.com"))
            {
                Person = this.person,
                Domain = { this.domain }
            });

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
        }
Beispiel #15
0
        public void Setup()
        {
            this.revision = typeof(Thing).GetProperty("RevisionNumber");

            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

            this.SetupIRuleVerificationService();

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

            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.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.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);
        }
Beispiel #16
0
        public void SetUp()
        {
            this.ribbonManager                = new Mock <IFluentRibbonManager>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.pluginSettingsService        = new Mock <IPluginSettingsService>();

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

            this.siteDirectory         = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "TST", Name = "Test"
            };
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationNumber = 1, Description = "iteraiton 1"
            };
            this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup);
            this.siteDirectory.Model.Add(this.engineeringModelSetup);
            this.person = new Person(Guid.NewGuid(), this.cache, this.uri)
            {
                GivenName = "John", Surname = "Doe"
            };
            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.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.engineeringModelSetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationSetup
            };
            this.engineeringModel.Iteration.Add(this.iteration);
            this.modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.siteReferenceDataLibrary  = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.engineeringModelSetup.RequiredRdl.Add(this.modelReferenceDataLibrary);
            this.modelReferenceDataLibrary.RequiredRdl = this.siteReferenceDataLibrary;
            this.siteDirectory.SiteReferenceDataLibrary.Add(this.siteReferenceDataLibrary);

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

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDirectory);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.domain);
        }
Beispiel #17
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.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.thingCreator = new Mock <IThingCreator>();

            var siteDirectory         = new SiteDirectory();
            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var iterationsetup        = new IterationSetup();
            var engineeringModel      = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelSetup = engineeringModelSetup
            };

            engineeringModelSetup.IterationSetup.Add(iterationsetup);

            var siteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);

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

            var person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                GivenName = "test", Surname = "test"
            };
            var participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Person = person
            };

            engineeringModelSetup.Participant.Add(participant);

            this.session.Setup(x => x.ActivePerson).Returns(person);
            this.iteration = new Iteration(Guid.NewGuid(), null, this.uri)
            {
                IterationSetup = iterationsetup
            };
            engineeringModel.Iteration.Add(this.iteration);
            siteDirectory.Model.Add(engineeringModelSetup);

            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(null, participant) }
            });
        }
        public void VerifyAfterDelete()
        {
            var removeIiterationSetup = new IterationSetup(Guid.NewGuid(), 1);
            var originalThing         = removeIiterationSetup.DeepClone <Thing>();

            this.iterationSetupSideEffect.AfterDelete(removeIiterationSetup, this.engineeringModelSetup, originalThing, this.npgsqlTransaction, "siteDirectory", this.mockedSecurityContext.Object);

            // Check that a new iteration is created triggered by the the IterationSetup creation
            this.mockedIterationService.Verify(x => x.DeleteConcept(this.npgsqlTransaction, It.Is <string>(s => s.Contains("EngineeringModel")), It.IsAny <Iteration>(), It.IsAny <EngineeringModel>()), Times.Never);
        }
        public void SetUp()
        {
            this.session = new Mock <ISession>();

            this.iterationSetup = new IterationSetup(Guid.NewGuid(), null, null);

            var iterationNumber = typeof(IterationSetup).GetProperty("IterationNumber");

            iterationNumber.SetValue(this.iterationSetup, 1);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="IterationSetupDialogViewModel"/> class
 /// </summary>
 /// <param name="iterationSetup">
 /// The <see cref="IterationSetup"/> that is the subject of the current view-model. This is the object
 /// that will be either created, or edited.
 /// </param>
 /// <param name="thingTransaction">
 /// The <see cref="ThingTransaction"/> that contains the log of recorded changes.
 /// </param>
 /// <param name="session">
 /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated
 /// </param>
 /// <param name="isRoot">
 /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/>
 /// </param>
 /// <param name="dialogKind">
 /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs
 /// </param>
 /// <param name="thingDialogNavigationService">
 /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>.
 /// </param>
 /// <param name="container">
 /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog
 /// </param>
 /// <param name="chainOfContainers">
 /// The optional chain of containers that contains the <paramref name="container"/> argument
 /// </param>
 public IterationSetupDialogViewModel(IterationSetup iterationSetup, IThingTransaction thingTransaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers = null)
     : base(iterationSetup, thingTransaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers)
 {
     this.WhenAnyValue(x => x.SelectedSourceIterationSetupRow)
     .Subscribe(x =>
     {
         this.SelectedSourceIterationSetup = (x == null) ? null : x.IterationSetup;
         this.UpdateOkCanExecute();
     });
 }
Beispiel #21
0
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();
            var dal = new Mock <IDal>();

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

            this.siteDir        = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.siteDir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.siteDir.SiteReferenceDataLibrary.Add(this.srdl);
            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)
            {
                IterationSetup = this.iterationsetup
            };
            this.requirement          = new Requirement(Guid.NewGuid(), this.cache, this.uri);
            this.relationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri);
            this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), this.cache, this.uri);
            this.requirement.ParametricConstraint.Add(this.parametricConstraint);
            this.parametricConstraint.Expression.Add(this.relationalExpression);
            this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Requirement.Add(this.requirement);
            this.grp = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Group.Add(this.grp);
            this.cache.TryAdd(new CacheKey(this.reqSpec.Iid, null), new Lazy <Thing>(() => this.reqSpec));

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

            this.clone = this.parametricConstraint.Clone(false);
            var transactionContext = TransactionContextResolver.ResolveContext(this.iteration);

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

            this.dateRelationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri);
            this.dateRelationalExpression.ParameterType = new DateParameterType();
            this.dateRelationalExpression.Value         = new ValueArray <string>(new[] { "2019-12-31" });
        }
Beispiel #22
0
        public void Setup()
        {
            this.assembler = new Assembler(this.uri);

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

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

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

            this.iteration.RequirementsSpecification.Add(this.reqSpec);
            this.iteration.IterationSetup    = this.iterationSetup;
            this.model.EngineeringModelSetup = this.modelSetup;
            this.model.Iteration.Add(this.iteration);

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

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

            this.req = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "requirement1", ShortName = "r1", Owner = this.domain
            };
            this.def = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Content = "def"
            };
            this.reqSpec.Requirement.Add(this.req);
            this.req.Definition.Add(this.def);
        }
        public void VerifyThatConvertIterationSetupProvidesTheExpectedIcon()
        {
            const string iterationSetupGrayIcon = "pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/grayscaleIterationSetup_16x16.png";
            var          iterationSetup         = new IterationSetup();
            var          converterResult        = (BitmapImage)this.converter.Convert(new object[] { iterationSetup }, null, null, null);

            Assert.AreNotEqual(iterationSetupGrayIcon, converterResult.UriSource.ToString());

            converterResult = (BitmapImage)this.converter.Convert(new object[] { iterationSetup, RowStatusKind.Inactive }, null, null, null);
            Assert.AreEqual(iterationSetupGrayIcon, converterResult.UriSource.ToString());
        }
Beispiel #24
0
        /// <summary>
        /// The setup transaction.
        /// </summary>
        /// <param name="connection">
        /// The connection.
        /// </param>
        /// <param name="credentials">
        /// The credentials.
        /// </param>
        /// <param name="iterationIid">
        /// The iteration context to use.
        /// </param>
        /// <returns>
        /// The <see cref="NpgsqlTransaction"/>.
        /// </returns>
        public NpgsqlTransaction SetupTransaction(ref NpgsqlConnection connection, Credentials credentials, Guid iterationIid)
        {
            var transaction = this.GetTransaction(ref connection, credentials);

            if (iterationIid != Guid.Empty)
            {
                this.IterationSetup = this.GetIterationContext(transaction, iterationIid);
            }

            return(transaction);
        }
Beispiel #25
0
        public void Setup()
        {
            this.permissionService            = new Mock <IPermissionService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.session = new Mock <ISession>();
            this.domain  = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain", ShortName = "dom"
            };

            this.siteDir        = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.model          = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.modelSetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iteration      = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.participant    = new Participant(Guid.NewGuid(), this.cache, this.uri);
            this.option         = new Option(Guid.NewGuid(), this.cache, this.uri);
            this.elementDef     = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };
            this.elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ElementDefinition = this.elementDef2, Owner = this.domain
            };

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

            this.model.Iteration.Add(this.iteration);
            this.model.EngineeringModelSetup = this.modelSetup;
            this.iteration.IterationSetup    = this.iterationSetup;
            this.iteration.Option.Add(this.option);
            this.iteration.TopElement = this.elementDef;
            this.iteration.Element.Add(this.elementDef);
            this.iteration.Element.Add(this.elementDef2);
            this.elementDef.ContainedElement.Add(this.elementUsage);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.domain);
        }
Beispiel #26
0
        public void VerifyThatPropertiesAreSet()
        {
            var iterationSetup = new IterationSetup();

            var vm = new IterationSetupDialogViewModel(iterationSetup, this.transaction, this.session.Object, true,
                                                       ThingDialogKind.Create, this.navigation.Object, this.clone);

            Assert.AreEqual(1, vm.PossibleSourceIterationSetupRow.Count);
            Assert.IsNull(vm.NullableCreatedOn);
            Assert.IsNull(vm.NullableIterationNumber);
        }
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                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.option = new Option(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "o", Name = "option"
            };
            this.model.Iteration.Add(this.iteration);
            this.iteration.Option.Add(this.option);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.domain);

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
        }
Beispiel #28
0
        public async Task VerifyThatOkCommandWorksWhenRoot()
        {
            var iterationSetup = new IterationSetup();

            var vm = new IterationSetupDialogViewModel(iterationSetup, this.transaction, this.session.Object, true,
                                                       ThingDialogKind.Create, this.navigation.Object, this.clone);

            vm.OkCommand.Execute(null);
            Assert.IsNotNull(iterationSetup.SourceIterationSetup);
            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));
            Assert.IsTrue(vm.DialogResult.Value);
        }
Beispiel #29
0
        public void Setup()
        {
            this.rev = typeof(Thing).GetProperty("RevisionNumber");

            this.session           = new Mock <ISession>();
            this.assembler         = new Assembler(this.uri);
            this.permissionService = new Mock <IPermissionService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                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.Assembler).Returns(this.assembler);

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

            this.parameterActualFiniteStateListApplicationBatchService = new Mock <IParameterActualFiniteStateListApplicationBatchService>();
        }
        public async Task VerifyThatIterationIsDeletedWhenSetupIsDeleted()
        {
            var assembler = new Assembler(this.uri);

            var model = new EngineeringModel(Guid.NewGuid(), assembler.Cache, this.uri);
            var it1   = new Iteration(Guid.NewGuid(), assembler.Cache, this.uri);
            var it2   = new Iteration(Guid.NewGuid(), assembler.Cache, this.uri);

            model.Iteration.Add(it1);
            model.Iteration.Add(it2);

            var sitedir    = new SiteDirectory(Guid.NewGuid(), assembler.Cache, this.uri);
            var modelsetup = new EngineeringModelSetup(Guid.NewGuid(), assembler.Cache, this.uri)
            {
                EngineeringModelIid = model.Iid
            };
            var iterationsetup1 = new IterationSetup(Guid.NewGuid(), assembler.Cache, this.uri)
            {
                IterationIid = it1.Iid
            };
            var iterationsetup2 = new IterationSetup(Guid.NewGuid(), assembler.Cache, this.uri)
            {
                IterationIid = it2.Iid
            };

            sitedir.Model.Add(modelsetup);
            modelsetup.IterationSetup.Add(iterationsetup1);
            modelsetup.IterationSetup.Add(iterationsetup2);

            assembler.Cache.TryAdd(new CacheKey(sitedir.Iid, null), new Lazy <Thing>(() => sitedir));
            assembler.Cache.TryAdd(new CacheKey(modelsetup.Iid, null), new Lazy <Thing>(() => modelsetup));
            assembler.Cache.TryAdd(new CacheKey(iterationsetup1.Iid, null), new Lazy <Thing>(() => iterationsetup1));
            assembler.Cache.TryAdd(new CacheKey(iterationsetup2.Iid, null), new Lazy <Thing>(() => iterationsetup2));
            assembler.Cache.TryAdd(new CacheKey(model.Iid, null), new Lazy <Thing>(() => model));
            assembler.Cache.TryAdd(new CacheKey(it1.Iid, null), new Lazy <Thing>(() => it1));
            assembler.Cache.TryAdd(new CacheKey(it2.Iid, null), new Lazy <Thing>(() => it2));

            var sitedirdto = new Dto.SiteDirectory(sitedir.Iid, 1);

            sitedirdto.Model.Add(modelsetup.Iid);

            var itdto = (Dto.IterationSetup)iterationsetup1.ToDto();

            itdto.IsDeleted = true;

            Assert.IsTrue(assembler.Cache.ContainsKey(new CacheKey(it1.Iid, null)));
            await assembler.Synchronize(new List <Dto.Thing> {
                sitedirdto, itdto
            });

            Assert.IsFalse(assembler.Cache.ContainsKey(new CacheKey(it1.Iid, null)));
        }