Ejemplo n.º 1
0
        public void VerifyThatOptionDependentStateDependentParameterValueSetReturnsExpectedModelCode()
        {
            var option = new Option(Guid.NewGuid(), null, null);

            option.ShortName = "option_1";

            this.parameter.IsOptionDependent    = true;
            this.parameterValueSet.ActualOption = option;

            var possibleFiniteStateList = new PossibleFiniteStateList();
            var possibleFiniteState     = new PossibleFiniteState();

            possibleFiniteState.ShortName = "SM";
            possibleFiniteStateList.PossibleState.Add(possibleFiniteState);

            var actualFiniteStateList = new ActualFiniteStateList();

            actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList);
            var actualFiniteState = new ActualFiniteState();

            actualFiniteState.PossibleState.Add(possibleFiniteState);
            actualFiniteStateList.ActualState.Add(actualFiniteState);

            this.parameter.StateDependence     = actualFiniteStateList;
            this.parameterValueSet.ActualState = actualFiniteState;

            Assert.AreEqual(@"Sat.m\option_1\SM", this.parameterValueSet.ModelCode(0));
        }
Ejemplo n.º 2
0
        public void VerifyThatStateDependentParameterOverrideValueSetReturnsExpectedModelCode()
        {
            var possibleFiniteStateList = new PossibleFiniteStateList();
            var possibleFiniteState     = new PossibleFiniteState();

            possibleFiniteState.ShortName = "SM";
            possibleFiniteStateList.PossibleState.Add(possibleFiniteState);

            var actualFiniteStateList = new ActualFiniteStateList();

            actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList);
            var actualFiniteState = new ActualFiniteState();

            actualFiniteState.PossibleState.Add(possibleFiniteState);
            actualFiniteStateList.ActualState.Add(actualFiniteState);

            this.scalarParameter.StateDependence = actualFiniteStateList;
            var parameterValueSet = this.scalarParameter.ValueSet.Single();

            parameterValueSet.ActualState = actualFiniteState;

            var parameterOverride = new ParameterOverride();

            parameterOverride.Parameter = this.scalarParameter;
            this.elementUsage.ParameterOverride.Add(parameterOverride);

            var parameterOverrideValueSet = new ParameterOverrideValueSet();

            parameterOverrideValueSet.ParameterValueSet = parameterValueSet;
            parameterOverride.ValueSet.Add(parameterOverrideValueSet);

            parameterOverrideValueSet.ParameterValueSet = parameterValueSet;

            Assert.AreEqual(@"Sat.battery_1.l\SM", parameterOverrideValueSet.ModelCode(0));
        }
        public void SetUp()
        {
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.possibleFiniteStateList_1 = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            this.possibleFiniteState_1_1   = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.possibleFiniteState_1_2   = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.possibleFiniteStateList_1.PossibleState.Add(this.possibleFiniteState_1_1);
            this.possibleFiniteStateList_1.PossibleState.Add(this.possibleFiniteState_1_2);

            this.possibleFiniteStateList_2 = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            this.possibleFiniteState_2_1   = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.possibleFiniteState_2_2   = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.possibleFiniteStateList_2.PossibleState.Add(this.possibleFiniteState_2_1);
            this.possibleFiniteStateList_2.PossibleState.Add(this.possibleFiniteState_2_2);

            this.actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            this.actualFiniteStateList.PossibleFiniteStateList.Insert(1, this.possibleFiniteStateList_1);
            this.actualFiniteState_1 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.actualFiniteState_1.PossibleState.Add(this.possibleFiniteState_1_1);
            this.actualFiniteState_2 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.actualFiniteState_2.PossibleState.Add(this.possibleFiniteState_1_2);
            this.actualFiniteState_3 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.actualFiniteState_3.PossibleState.Add(this.possibleFiniteState_2_1);
            this.actualFiniteState_4 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);
            this.actualFiniteState_4.PossibleState.Add(this.possibleFiniteState_2_2);
            this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_1);
            this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_2);
            this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_3);
            this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_4);

            this.comparer = new ActualFiniteStateComparer();
        }
Ejemplo n.º 4
0
        public void VerifyThatGetPathWorks()
        {
            // **************************INPUT***************************************
            var published = new ValueArray <string>(new List <string> {
                "manual1", "manual2"
            }, this.valueset);
            var actual = new ValueArray <string>(new List <string> {
                "manual1", "manual2"
            }, this.valueset);

            this.valueset.Published    = published;
            this.valueset.Manual       = actual;
            this.valueset.ValueSwitch  = ParameterSwitchKind.MANUAL;
            this.valueset.ActualOption = this.option;

            var compoundtype = new CompoundParameterType(Guid.NewGuid(), null, this.uri);

            var component1 = new ParameterTypeComponent(Guid.NewGuid(), null, this.uri)
            {
                ParameterType = this.parameterType1,
                ShortName     = "c1"
            };

            var component2 = new ParameterTypeComponent(Guid.NewGuid(), null, this.uri)
            {
                ParameterType = this.parameterType1,
                ShortName     = "c2"
            };

            compoundtype.Component.Add(component1);
            compoundtype.Component.Add(component2);

            var state2 = new ActualFiniteState(Guid.NewGuid(), null, this.uri);

            this.stateList.ActualState.Add(state2);

            this.parameter1.ParameterType = compoundtype;
            this.parameter1.ValueSet.Add(this.valueset);
            this.parameter1.IsOptionDependent = true;

            var valueset2 = new ParameterValueSet(Guid.NewGuid(), null, this.uri)
            {
                ActualState = state2,
                Published   = published
            };

            this.parameter1.ValueSet.Add(valueset2);

            var row = new ParameterRowViewModel(this.parameter1, this.option, this.session.Object, null);

            Assert.AreEqual(this.nestedParameterPath, row.GetPath());

            var row2 = new ParameterTypeComponentRowViewModel(compoundtype.Component.First(), this.session.Object, null);

            Assert.AreEqual(string.Empty, row2.GetPath());

            var row3 = new ParameterTypeComponentRowViewModel(compoundtype.Component.First(), this.session.Object, row);

            Assert.AreEqual(this.nestedParameterPath, row3.GetPath());
        }
Ejemplo n.º 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();
        }
        public void VerifyThatTreeIsCorrectlyBuilt()
        {
            var possibleFiniteStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri);

            this.iteration.PossibleFiniteStateList.Add(possibleFiniteStateList);
            var possibleFiniteState = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);

            possibleFiniteStateList.PossibleState.Add(possibleFiniteState);

            var actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri);

            actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList);

            this.iteration.ActualFiniteStateList.Add(actualFiniteStateList);
            var row = new ActualFiniteStateListRowViewModel(actualFiniteStateList, this.session.Object, null);

            Assert.IsEmpty(row.ContainedRows);
            var state = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);

            state.PossibleState.Add(possibleFiniteState);
            actualFiniteStateList.ActualState.Add(state);

            this.rev.SetValue(actualFiniteStateList, 2);
            CDPMessageBus.Current.SendObjectChangeEvent(actualFiniteStateList, EventKind.Updated);
            var staterow = (ActualFiniteStateRowViewModel)row.ContainedRows.SingleOrDefault();

            Assert.IsNotNull(staterow);
        }
Ejemplo n.º 7
0
        public void Verify_that_ExecuteBatchUpdateParameterCommand_works_as_expected()
        {
            var possibleList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            var ps           = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);

            possibleList.PossibleState.Add(ps);

            this.iteration.PossibleFiniteStateList.Add(possibleList);

            var actualList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri);

            actualList.PossibleFiniteStateList.Add(possibleList);
            var astate = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);

            astate.PossibleState.Add(ps);

            actualList.ActualState.Add(astate);

            this.iteration.ActualFiniteStateList.Add(actualList);
            var dialogResult = new CDP4EngineeringModel.ViewModels.Dialogs.CategoryDomainParameterTypeSelectorResult(true, false, Enumerable.Empty <ParameterType>(), Enumerable.Empty <Category>(), Enumerable.Empty <DomainOfExpertise>());

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

            var vm = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, null, null, this.dialogNavigationService.Object, null, this.parameterActualFiniteStateListApplicationBatchService.Object);

            vm.SelectedThing = new ActualFiniteStateListRowViewModel(actualList, this.session.Object, null);

            vm.BatchUpdateParameterCommand.Execute(null);

            this.dialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <IDialogViewModel>()), Times.Exactly(1));

            this.parameterActualFiniteStateListApplicationBatchService.Verify(x => x.Update(this.session.Object, this.iteration, It.IsAny <ActualFiniteStateList>(), false, It.IsAny <IEnumerable <Category> >(), It.IsAny <IEnumerable <DomainOfExpertise> >(), It.IsAny <IEnumerable <ParameterType> >()), Times.Exactly(1));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the <see cref="ParameterValueSetBase"/> for an <see cref="Option"/> (if this <see cref="ParameterOrOverrideBase"/> is option dependent) and a <see cref="ActualFiniteState"/> (if it is state dependent)
        /// </summary>
        /// <param name="actualState">The <see cref="ActualFiniteState"/></param>
        /// <param name="actualOption">The <see cref="Option"/></param>
        /// <returns>The <see cref="ParameterValueSetBase"/> if a value is defined for the <see cref="Option"/></returns>
        protected override ParameterValueSetBase GetValueSet(ActualFiniteState actualState = null, Option actualOption = null)
        {
            var isStateDependent  = this.StateDependence != null;
            var parameterOverride = (ParameterOverride)this.Thing;
            var valueset          = parameterOverride.ValueSet.SingleOrDefault(x => (!isStateDependent || x.ActualState == actualState) && (!this.IsOptionDependent || x.ActualOption == actualOption));

            return(valueset);
        }
Ejemplo n.º 9
0
 public void VerifyThatNullContainerThrowException3()
 {
     this.actualFiniteState = new ActualFiniteState(Guid.NewGuid(), null, null);
     Assert.Throws <ContainmentException>(() =>
     {
         Console.WriteLine(this.actualFiniteState.Owner);
     });
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParameterStateRowViewModel"/> class
 /// </summary>
 /// <param name="parameterBase">The associated value-set of a <see cref="ParameterBase"/></param>
 /// <param name="actualFiniteState">The <see cref="ActualFiniteState"/> represented</param>
 /// <param name="session">The <see cref="ISession"/></param>
 /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
 public ParameterStateRowViewModel(ParameterBase parameterBase, ActualFiniteState actualFiniteState, ISession session, IViewModelBase <Thing> containerViewModel)
     : base(parameterBase, session, containerViewModel)
 {
     this.IsPublishable = false;
     this.ActualState   = actualFiniteState;
     this.IsDefault     = this.ActualState.IsDefault;
     this.Name          = this.ActualState.Name;
 }
Ejemplo n.º 11
0
        public void VerifyUpdatePropertiesBasedOnMappingConfiguration()
        {
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null);

            this.hubController.Setup(x => x.GetThingById(It.IsAny <Guid>(), It.IsAny <Iteration>(), out elementDefinition)).Returns(true);

            var parameter = new Parameter(Guid.NewGuid(), null, null);

            this.hubController.Setup(x => x.GetThingById(It.IsAny <Guid>(), It.IsAny <Iteration>(), out parameter)).Returns(true);

            var option = new Option(Guid.NewGuid(), null, null);

            this.hubController.Setup(x => x.GetThingById(It.IsAny <Guid>(), It.IsAny <Iteration>(), out option)).Returns(true);

            var state = new ActualFiniteState(Guid.NewGuid(), null, null);

            this.hubController.Setup(x => x.GetThingById(It.IsAny <Guid>(), It.IsAny <Iteration>(), out state)).Returns(true);

            var elementUsage = new ElementUsage(Guid.NewGuid(), null, null);

            this.hubController.Setup(x => x.GetThingById(It.IsAny <Guid>(), It.IsAny <Iteration>(), out elementUsage)).Returns(true);

            var correspondences = new List <IdCorrespondence>
            {
                new IdCorrespondence()
                {
                    ExternalId = "trans0", InternalThing = elementDefinition.Iid
                },
                new IdCorrespondence()
                {
                    ExternalId = "res0", InternalThing = parameter.Iid
                },
                new IdCorrespondence()
                {
                    ExternalId = "trans0", InternalThing = option.Iid
                },
                new IdCorrespondence()
                {
                    ExternalId = "trans0", InternalThing = state.Iid
                },
                new IdCorrespondence()
                {
                    ExternalId = "res0", InternalThing = elementUsage.Iid
                },
            };

            foreach (var variable in this.viewModel.Variables)
            {
                variable.MappingConfigurations.AddRange(
                    correspondences.Where(
                        x => x.ExternalId == variable.ElementName ||
                        x.ExternalId == variable.ParameterName));
            }

            Assert.DoesNotThrow(() => this.viewModel.UpdatePropertiesBasedOnMappingConfiguration());
            this.hubController.Verify(x => x.GetThingById(It.IsAny <Guid>(), It.IsAny <Iteration>(), out It.Ref <Thing> .IsAny), Times.Exactly(5));
        }
        public void Verify_that_when_containers_are_not_the_same_exception_is_thrown()
        {
            var otherActualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            var otherActualFiniteState     = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);

            otherActualFiniteStateList.ActualState.Add(otherActualFiniteState);

            Assert.Throws <InvalidOperationException>(() => this.comparer.Compare(this.actualFiniteState_1, otherActualFiniteState));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterValueBaseRowViewModel"/> class
        /// </summary>
        /// <param name="parameterBase">
        /// The associated <see cref="ParameterBase"/>
        /// </param>
        /// <param name="session">
        /// The <see cref="ISession"/>
        /// </param>
        /// <param name="actualOption">
        /// The actual <see cref="Option"/> represented if any
        /// </param>
        /// <param name="actualState">
        /// The actual <see cref="ActualFiniteState"/> represented if any
        /// </param>
        /// <param name="containerRow">
        /// The row container
        /// </param>
        /// <param name="valueIndex">
        /// The index of the component if applicable
        /// </param>
        /// <param name="isReadOnly">
        /// A value indicating whether the row is read-only
        /// </param>
        protected ParameterValueBaseRowViewModel(ParameterBase parameterBase, ISession session, Option actualOption, ActualFiniteState actualState, IViewModelBase <Thing> containerRow, int valueIndex = 0, bool isReadOnly = false)
            : base(parameterBase, session, containerRow)
        {
            this.isParameterBaseReadOnlyInDataContext = isReadOnly;
            this.ActualOption = actualOption;
            this.ActualState  = actualState;

            this.ValueIndex             = valueIndex;
            this.ParameterTypeClassKind = this.Thing.ParameterType.ClassKind;

            this.SetOwnerValue();
        }
        private void SetupFiniteStates()
        {
            this.ActualPossibleFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.Assembler.Cache, this.uri);

            var possibleStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.Assembler.Cache, this.uri)
            {
                ShortName = "actualFiniteStateListTest"
            };
            var possibleState1 = new PossibleFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri)
            {
                Name = "1"
            };
            var possibleState2 = new PossibleFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri)
            {
                Name = "2"
            };
            var possibleState3 = new PossibleFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri)
            {
                Name = "3"
            };

            possibleStateList.PossibleState.Add(possibleState1);
            possibleStateList.PossibleState.Add(possibleState2);
            possibleStateList.PossibleState.Add(possibleState3);

            this.Iteration.PossibleFiniteStateList.Add(possibleStateList);
            this.ActualPossibleFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.Assembler.Cache, this.uri);
            var actualState1 = new ActualFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    possibleState1
                }
            };
            var actualState2 = new ActualFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    possibleState2
                }
            };
            var actualState3 = new ActualFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri)
            {
                PossibleState = new List <PossibleFiniteState> {
                    possibleState3
                }
            };

            this.ActualPossibleFiniteStateList.ActualState.Add(actualState1);
            this.ActualPossibleFiniteStateList.ActualState.Add(actualState2);
            this.ActualPossibleFiniteStateList.ActualState.Add(actualState3);

            this.ActualPossibleFiniteStateList.PossibleFiniteStateList.Add(possibleStateList);
            this.Iteration.ActualFiniteStateList.Add(this.ActualPossibleFiniteStateList);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ActualFiniteStateRowViewModel"/> class
        /// </summary>
        /// <param name="actualFiniteState">The <see cref="ActualFiniteState"/> represented</param>
        /// <param name="session">The <see cref="ISession"/></param>
        /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
        public ActualFiniteStateRowViewModel(ActualFiniteState actualFiniteState, ISession session, IViewModelBase <Thing> containerViewModel)
            : base(actualFiniteState, session, containerViewModel)
        {
            this.IsPublishable = false;

            var parameterOrOverrideBaseRowViewModel = containerViewModel as ParameterOrOverrideBaseRowViewModel;

            if (parameterOrOverrideBaseRowViewModel != null)
            {
                this.OwnerShortName = parameterOrOverrideBaseRowViewModel.OwnerShortName;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new instance of the <see cref="ParameterToStateMapping"/> class
        /// </summary>
        /// <param name="value">The value</param>
        /// <param name="parameterType">The <see cref="ParameterType"/> that was mapped</param>
        /// <param name="actualFiniteState">The <see cref="ActualFiniteState"/></param>
        /// <param name="shortName">ShortName to add to the mapping</param>
        public ParameterToStateMapping(string value, ParameterType parameterType, ActualFiniteState actualFiniteState, string shortName)
        {
            this.ParameterTypeIid       = parameterType.Iid;
            this.ParameterTypeName      = parameterType.Name;
            this.ParameterTypeShortName = parameterType.ShortName;

            this.ActualFiniteStateIid       = actualFiniteState.Iid;
            this.ActualFiniteStateShortName = actualFiniteState.ShortName;
            this.ActualFiniteStateName      = actualFiniteState.Name;

            this.Value     = value;
            this.ShortName = shortName;
        }
        public void VerifyThatContainerSetToClone()
        {
            var list = new ActualFiniteStateList();
            var state = new ActualFiniteState();
            list.ActualState.Add(state);

            var clone = list.Clone(false);
            Assert.AreSame(list, state.Container);

            clone.ActualState.Clear();
            clone.ActualState.Add(state);

            Assert.AreSame(clone, state.Container);
        }
        /// <summary>
        /// Serialize the <see cref="ActualFiniteState"/>
        /// </summary>
        /// <param name="actualFiniteState">The <see cref="ActualFiniteState"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(ActualFiniteState actualFiniteState)
        {
            var jsonObject = new JObject();

            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), actualFiniteState.ClassKind)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](actualFiniteState.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](actualFiniteState.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](actualFiniteState.Iid));
            jsonObject.Add("kind", this.PropertySerializerMap["kind"](Enum.GetName(typeof(CDP4Common.EngineeringModelData.ActualFiniteStateKind), actualFiniteState.Kind)));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](actualFiniteState.ModifiedOn));
            jsonObject.Add("possibleState", this.PropertySerializerMap["possibleState"](actualFiniteState.PossibleState.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](actualFiniteState.RevisionNumber));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](actualFiniteState.ThingPreference));
            return(jsonObject);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterStateRowViewModel"/> class
        /// </summary>
        /// <param name="parameterBase">The associated value-set of a <see cref="ParameterBase"/></param>
        /// <param name="actualFiniteState">The <see cref="ActualFiniteState"/> represented</param>
        /// <param name="session">The <see cref="ISession"/></param>
        /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
        public ParameterStateRowViewModel(ParameterBase parameterBase, ActualFiniteState actualFiniteState, ISession session, IViewModelBase <Thing> containerViewModel)
            : base(parameterBase, session, containerViewModel)
        {
            this.IsPublishable = false;
            this.ActualState   = actualFiniteState;
            this.IsDefault     = this.ActualState.IsDefault;
            this.Name          = this.ActualState.Name;

            if (containerViewModel is ParameterOrOverrideBaseRowViewModel parameterOrOverrideBaseRowViewModel)
            {
                this.Option = parameterOrOverrideBaseRowViewModel.Option;
            }

            this.InitializeOptionSubscriptions();
        }
Ejemplo n.º 20
0
        public void VerifyThatContextMenuPopulated()
        {
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);


            var possibleList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri);
            var ps           = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri);

            possibleList.PossibleState.Add(ps);

            this.iteration.PossibleFiniteStateList.Add(possibleList);

            var actualList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri);

            actualList.PossibleFiniteStateList.Add(possibleList);
            var astate = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri);

            astate.PossibleState.Add(ps);

            actualList.ActualState.Add(astate);

            this.iteration.ActualFiniteStateList.Add(actualList);

            var viewmodel = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, null);

            // no row selected
            viewmodel.ComputePermission();
            viewmodel.PopulateContextMenu();
            Assert.AreEqual(2, viewmodel.ContextMenu.Count);

            // posible state row selected
            var pslFolder = viewmodel.FiniteStateList.First();
            var psRow     = pslFolder.ContainedRows.First().ContainedRows.First();

            viewmodel.SelectedThing = psRow;
            viewmodel.ComputePermission();
            viewmodel.PopulateContextMenu();
            Assert.AreEqual(8, viewmodel.ContextMenu.Count);

            // execute set default
            Assert.IsTrue(viewmodel.CanSetAsDefault);
            viewmodel.SetDefaultStateCommand.Execute(null);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Compare the two instances of <see cref="ActualFiniteState "/>
        /// </summary>
        /// <param name="x">
        /// the first instance of <see cref="ActualFiniteState"/> to compare.
        /// </param>
        /// <param name="y">
        /// the second instance of <see cref="ActualFiniteState"/> to compare.
        /// </param>
        /// <returns>
        /// Less than zero : x is less than y.
        /// Zero: x equals y.
        /// Greater than zero: x is greater than y.
        /// </returns>
        /// <remarks>
        /// the order is determined by the ordering in the container collection
        /// </remarks>
        private static int CompareActualState(ActualFiniteState x, ActualFiniteState y)
        {
            if (x == null && y == null)
            {
                return(0);
            }

            if (x == null && y != null)
            {
                return(1);
            }

            if (x != null && y == null)
            {
                return(-1);
            }

            var actualFiniteStateListX = (ActualFiniteStateList)x.Container;
            var actualFiniteStateListY = (ActualFiniteStateList)y.Container;

            if (actualFiniteStateListX != actualFiniteStateListY)
            {
                throw new InvalidOperationException("The ActualFiniteStates are not contained by the same ActualFiniteStateList and cannot be compared");
            }

            var indexX = actualFiniteStateListX.ActualState.IndexOf(x);
            var indexY = actualFiniteStateListY.ActualState.IndexOf(y);

            if (indexX < indexY)
            {
                return(-1);
            }

            if (indexX == indexY)
            {
                return(0);
            }

            if (indexX > indexY)
            {
                return(1);
            }

            return(0);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterValueBaseRowViewModel"/> class
        /// </summary>
        /// <param name="parameterBase">
        /// The associated <see cref="ParameterBase"/>
        /// </param>
        /// <param name="session">
        /// The <see cref="ISession"/>
        /// </param>
        /// <param name="actualOption">
        /// The actual <see cref="Option"/> represented if any
        /// </param>
        /// <param name="actualState">
        /// The actual <see cref="ActualFiniteState"/> represented if any
        /// </param>
        /// <param name="containerRow">
        /// The row container
        /// </param>
        /// <param name="valueIndex">
        /// The index of the component if applicable
        /// </param>
        /// <param name="isDialogReadOnly">
        /// Value indicating whether this row should be read-only because the dialog is read-only
        /// </param>
        protected ParameterValueBaseRowViewModel(ParameterBase parameterBase, ISession session, Option actualOption, ActualFiniteState actualState, IViewModelBase <Thing> containerRow, int valueIndex = 0, bool isDialogReadOnly = false)
            : base(parameterBase, session, containerRow)
        {
            this.ActualOption = actualOption;
            this.ActualState  = actualState;

            this.ValueIndex             = valueIndex;
            this.ParameterTypeClassKind = this.ParameterType.ClassKind;

            this.WhenAnyValue(vm => vm.Switch).Skip(1).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Manual).Skip(1).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Computed).Skip(1).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Reference).Skip(1).Subscribe(_ => this.UpdateActualValue());

            var option = this.ActualOption == null ? string.Empty : this.ActualOption.ShortName;
            var state  = this.ActualState == null ? string.Empty : this.ActualState.ShortName;

            this.RowCode = string.Format("{0}.{1}.{2}", option, state, this.ValueIndex);

            this.DialogViewModel = (IDialogViewModelBase <ParameterBase>) this.TopContainerViewModel;

            var subscription = this.Thing as ParameterSubscription;

            if (subscription != null)
            {
                var parameter = (ParameterOrOverrideBase)subscription.Container;
                if (parameter.Owner != null)
                {
                    this.OwnerName      = "[" + parameter.Owner.Name + "]";
                    this.OwnerShortName = "[" + parameter.Owner.ShortName + "]";
                }
            }
            else
            {
                if (this.Owner != null)
                {
                    this.OwnerName      = this.Owner.Name;
                    this.OwnerShortName = this.Owner.ShortName;
                }
            }
        }
Ejemplo n.º 23
0
        public void VerifyThatStateDependentParameterValueSetReturnsExpectedModelCode()
        {
            var possibleFiniteStateList = new PossibleFiniteStateList();
            var possibleFiniteState     = new PossibleFiniteState();

            possibleFiniteState.ShortName = "SM";
            possibleFiniteStateList.PossibleState.Add(possibleFiniteState);

            var actualFiniteStateList = new ActualFiniteStateList();

            actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList);
            var actualFiniteState = new ActualFiniteState();

            actualFiniteState.PossibleState.Add(possibleFiniteState);
            actualFiniteStateList.ActualState.Add(actualFiniteState);

            this.parameter.StateDependence     = actualFiniteStateList;
            this.parameterValueSet.ActualState = actualFiniteState;

            Assert.AreEqual(@"Sat.m\SM", this.parameterValueSet.ModelCode(0));
        }
Ejemplo n.º 24
0
        public void SetUp()
        {
            this.iteration = new Iteration(Guid.NewGuid(), null, null);
            this.optiona   = new Option(Guid.NewGuid(), null, null)
            {
                Name = "option a", ShortName = "optionb"
            };
            this.optionb = new Option(Guid.NewGuid(), null, null)
            {
                Name = "option b", ShortName = "optionb"
            };
            this.iteration.Option.Add(this.optionb);
            this.iteration.Option.Add(this.optiona);

            var possibleFiniteStateList = new PossibleFiniteStateList(Guid.NewGuid(), null, null);
            var possibleFiniteStatea    = new PossibleFiniteState(Guid.NewGuid(), null, null)
            {
                Name      = "state a",
                ShortName = "statea"
            };
            var possibleFiniteStateb = new PossibleFiniteState(Guid.NewGuid(), null, null)
            {
                Name      = "state b",
                ShortName = "stateb"
            };

            possibleFiniteStateList.PossibleState.Add(possibleFiniteStateb);
            possibleFiniteStateList.PossibleState.Add(possibleFiniteStatea);
            this.iteration.PossibleFiniteStateList.Add(possibleFiniteStateList);

            var actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), null, null);

            this.actualFiniteStatea = new ActualFiniteState(Guid.NewGuid(), null, null);
            this.actualFiniteStatea.PossibleState.Add(possibleFiniteStatea);
            this.actualFiniteStateb = new ActualFiniteState(Guid.NewGuid(), null, null);
            this.actualFiniteStateb.PossibleState.Add(possibleFiniteStateb);
            actualFiniteStateList.ActualState.Add(this.actualFiniteStateb);
            actualFiniteStateList.ActualState.Add(this.actualFiniteStatea);
            this.iteration.ActualFiniteStateList.Add(actualFiniteStateList);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Creates and returns a new parameter value set for the given option and state
 /// </summary>
 /// <param name="option">
 /// The option.
 /// </param>
 /// <param name="state">
 /// The state.
 /// </param>
 /// <returns>
 /// The <see cref="ParameterValueSet"/>.
 /// </returns>
 private ParameterValueSet GetNewParameterValueSet(Option option, ActualFiniteState state)
 {
     return(new ParameterValueSet(Guid.NewGuid(), null, this.uri)
     {
         ActualOption = option,
         ActualState = state,
         Computed = new ValueArray <string>(new List <string> {
             "-"
         }),
         Manual = new ValueArray <string>(new List <string> {
             "-"
         }),
         Reference = new ValueArray <string>(new List <string> {
             "-"
         }),
         Formula = new ValueArray <string>(new List <string> {
             "-"
         }),
         Published = new ValueArray <string>(new List <string> {
             "-"
         }),
         ValueSwitch = ParameterSwitchKind.COMPUTED
     });
 }
Ejemplo n.º 26
0
        public void Setup()
        {
            this.actualFiniteState = new ActualFiniteState(Guid.NewGuid(), null, null);
            this.actualList        = new ActualFiniteStateList(Guid.NewGuid(), null, null);
            this.actualList.Owner  = new DomainOfExpertise(Guid.NewGuid(), null, null);

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

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

            this.possibleList1.PossibleState.Add(this.possibleState1);
            this.possibleList2.PossibleState.Add(this.possibleState2);

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

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

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

            this.model.Iteration.Add(this.iteration);
            this.iteration.ActualFiniteStateList.Add(this.actualList);
            this.iteration.PossibleFiniteStateList.Add(this.possibleList1);
            this.iteration.PossibleFiniteStateList.Add(this.possibleList2);
            this.actualList.ActualState.Add(this.actualFiniteState);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Gets the actual float value associated to the <paramref name="pt"/> for a <see cref="ElementUsage"/>
        /// </summary>
        /// <param name="usage">The <see cref="ElementUsage"/></param>
        /// <param name="pt">The <see cref="QuantityKind"/></param>
        /// <param name="state">The state</param>
        /// <param name="option">The value associated to the option to get</param>
        /// <param name="domain">The current domain</param>
        /// <returns>The converted float value</returns>
        public static float?GetFloatActualValue(this ElementUsage usage, QuantityKind pt, ActualFiniteState state, Option option, DomainOfExpertise domain)
        {
            var   value = GetActualValue(usage, pt, state, option, domain);
            float converted;

            if (float.TryParse(value, out converted))
            {
                return(converted);
            }

            return(null);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Gets the actual value associated to the <paramref name="pt"/> for a <see cref="ElementUsage"/>
        /// </summary>
        /// <param name="usage">The <see cref="ElementUsage"/></param>
        /// <param name="pt">The <see cref="ParameterType"/></param>
        /// <param name="state">The state</param>
        /// <param name="option">The value associated to the option to get</param>
        /// <param name="domain">The current domain</param>
        /// <returns>The value</returns>
        public static string GetActualValue(this ElementUsage usage, ParameterType pt, ActualFiniteState state, Option option, DomainOfExpertise domain)
        {
            var parameterOrOverride = (ParameterOrOverrideBase)usage.ParameterOverride.FirstOrDefault(x => x.ParameterType.Iid.Equals(pt.Iid))
                                      ?? usage.ElementDefinition.Parameter.FirstOrDefault(x => x.ParameterType.Iid.Equals(pt.Iid));

            if (parameterOrOverride == null)
            {
                // no value found associated to the parameter-type
                return(null);
            }

            var parameterBase = (ParameterBase)parameterOrOverride.ParameterSubscription.FirstOrDefault(x => x.Owner.Iid.Equals(domain?.Iid)) ?? parameterOrOverride;
            var valueset      = parameterBase.ValueSets.FirstOrDefault(x => (x.ActualOption == null || x.ActualOption.Iid.Equals(option.Iid)) && (x.ActualState == null || x.ActualState.Iid.Equals(state?.Iid)));

            return(valueset?.ActualValue.FirstOrDefault());
        }
Ejemplo n.º 29
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> >());
        }
        public void VerifyThatActualFiniteStateKindIsUpdatedOnNewDefault()
        {
            var model     = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var possibleList2 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var possibleList3 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var ps11 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ps12 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var ps21 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ps22 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var ps31 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ps32 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            possibleList1.PossibleState.Add(ps11);
            possibleList1.PossibleState.Add(ps12);
            possibleList2.PossibleState.Add(ps21);
            possibleList2.PossibleState.Add(ps22);
            possibleList3.PossibleState.Add(ps31);
            possibleList3.PossibleState.Add(ps32);

            var actualList1 = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var actualList2 = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);

            actualList1.PossibleFiniteStateList.Add(possibleList1);
            actualList1.PossibleFiniteStateList.Add(possibleList2);
            var as11 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as11.PossibleState.Add(ps11);
            as11.PossibleState.Add(ps21);
            var as12 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as12.PossibleState.Add(ps11);
            as12.PossibleState.Add(ps22);
            var as13 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as13.PossibleState.Add(ps12);
            as13.PossibleState.Add(ps21);
            var as14 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as14.PossibleState.Add(ps12);
            as14.PossibleState.Add(ps22);

            actualList1.ActualState.Add(as11);
            actualList1.ActualState.Add(as12);
            actualList1.ActualState.Add(as13);
            actualList1.ActualState.Add(as14);

            actualList2.PossibleFiniteStateList.Add(possibleList2);
            actualList2.PossibleFiniteStateList.Add(possibleList3);
            var as21 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as21.PossibleState.Add(ps21);
            as21.PossibleState.Add(ps31);
            var as22 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as22.PossibleState.Add(ps21);
            as22.PossibleState.Add(ps32);
            var as23 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as23.PossibleState.Add(ps22);
            as23.PossibleState.Add(ps31);
            var as24 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as24.PossibleState.Add(ps22);
            as24.PossibleState.Add(ps32);

            actualList2.ActualState.Add(as21);
            actualList2.ActualState.Add(as22);
            actualList2.ActualState.Add(as23);
            actualList2.ActualState.Add(as24);

            model.Iteration.Add(iteration);
            iteration.PossibleFiniteStateList.Add(possibleList1);
            iteration.PossibleFiniteStateList.Add(possibleList2);
            iteration.PossibleFiniteStateList.Add(possibleList3);
            iteration.ActualFiniteStateList.Add(actualList1);
            iteration.ActualFiniteStateList.Add(actualList2);

            this.assembler.Cache.TryAdd(new CacheKey(model.Iid, null), new Lazy <Thing>(() => model));
            this.assembler.Cache.TryAdd(new CacheKey(iteration.Iid, null), new Lazy <Thing>(() => iteration));
            this.assembler.Cache.TryAdd(new CacheKey(possibleList1.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList1));
            this.assembler.Cache.TryAdd(new CacheKey(possibleList2.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList2));
            this.assembler.Cache.TryAdd(new CacheKey(possibleList3.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList3));
            this.assembler.Cache.TryAdd(new CacheKey(ps11.Iid, iteration.Iid), new Lazy <Thing>(() => ps11));
            this.assembler.Cache.TryAdd(new CacheKey(ps12.Iid, iteration.Iid), new Lazy <Thing>(() => ps12));
            this.assembler.Cache.TryAdd(new CacheKey(ps21.Iid, iteration.Iid), new Lazy <Thing>(() => ps21));
            this.assembler.Cache.TryAdd(new CacheKey(ps22.Iid, iteration.Iid), new Lazy <Thing>(() => ps22));
            this.assembler.Cache.TryAdd(new CacheKey(ps31.Iid, iteration.Iid), new Lazy <Thing>(() => ps31));
            this.assembler.Cache.TryAdd(new CacheKey(ps32.Iid, iteration.Iid), new Lazy <Thing>(() => ps32));
            this.assembler.Cache.TryAdd(new CacheKey(actualList1.Iid, iteration.Iid), new Lazy <Thing>(() => actualList1));
            this.assembler.Cache.TryAdd(new CacheKey(actualList2.Iid, iteration.Iid), new Lazy <Thing>(() => actualList2));
            this.assembler.Cache.TryAdd(new CacheKey(as11.Iid, iteration.Iid), new Lazy <Thing>(() => as11));
            this.assembler.Cache.TryAdd(new CacheKey(as12.Iid, iteration.Iid), new Lazy <Thing>(() => as12));
            this.assembler.Cache.TryAdd(new CacheKey(as13.Iid, iteration.Iid), new Lazy <Thing>(() => as13));
            this.assembler.Cache.TryAdd(new CacheKey(as14.Iid, iteration.Iid), new Lazy <Thing>(() => as14));
            this.assembler.Cache.TryAdd(new CacheKey(as21.Iid, iteration.Iid), new Lazy <Thing>(() => as21));
            this.assembler.Cache.TryAdd(new CacheKey(as22.Iid, iteration.Iid), new Lazy <Thing>(() => as22));
            this.assembler.Cache.TryAdd(new CacheKey(as23.Iid, iteration.Iid), new Lazy <Thing>(() => as23));
            this.assembler.Cache.TryAdd(new CacheKey(as24.Iid, iteration.Iid), new Lazy <Thing>(() => as24));

            possibleList1.DefaultState = ps11;
            as11.Kind = ActualFiniteStateKind.FORBIDDEN;

            var transactionContext = TransactionContextResolver.ResolveContext(iteration);
            var context            = transactionContext.ContextRoute();

            var operationContainer = new OperationContainer(context, model.RevisionNumber);

            var original = possibleList2.ToDto();
            var modify   = (CDP4Common.DTO.PossibleFiniteStateList)possibleList2.ToDto();

            modify.DefaultState = ps21.Iid;

            operationContainer.AddOperation(new Operation(original, modify, OperationKind.Update));

            Assert.AreEqual(1, operationContainer.Operations.Count());

            var modifier = new OperationModifier(this.session.Object);

            modifier.ModifyOperationContainer(operationContainer);

            Assert.AreEqual(2, operationContainer.Operations.Count());
            var addedOperation      = operationContainer.Operations.Last();
            var originalActualState = (CDP4Common.DTO.ActualFiniteState)addedOperation.OriginalThing;
            var modifiedActualState = (CDP4Common.DTO.ActualFiniteState)addedOperation.ModifiedThing;

            Assert.AreEqual(as11.Iid, originalActualState.Iid);
            Assert.AreEqual(ActualFiniteStateKind.MANDATORY, modifiedActualState.Kind);
            Assert.AreEqual(ActualFiniteStateKind.FORBIDDEN, originalActualState.Kind);
        }