Exemplo n.º 1
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());
        }
Exemplo n.º 2
0
        public void VerifyThatPropertiesArePopulatedForScalarPropertiesWithOption()
        {
            // **********************************************************************
            var published = new ValueArray <string>(new List <string> {
                "manual"
            }, this.valueset);
            var actual = new ValueArray <string>(new List <string> {
                "manual"
            }, this.valueset);

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

            this.valueset.ActualOption = this.option;

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

            var valueset2 = new ParameterValueSet(Guid.NewGuid(), null, this.uri);

            this.parameter1.ValueSet.Add(valueset2);

            // **********************************************************************

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

            Assert.IsFalse(row.IsPublishable);
            Assert.IsTrue(row.Value.Contains("manual"));
            Assert.IsNull(row.StateDependence);
            Assert.IsNull(row.MeasurementScale);
            Assert.AreEqual(0, row.ContainedRows.Count);
            Assert.AreEqual("domain", row.OwnerName);
            Assert.AreEqual("dom", row.OwnerShortName);
        }
Exemplo n.º 3
0
        public void VerifyThatParameterTypeUpdatesAreHandled()
        {
            // **********************************************************************
            var published = new ValueArray <string>(new List <string> {
                "manual"
            }, this.valueset);
            var actual = new ValueArray <string>(new List <string> {
                "different"
            }, this.valueset);

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

            this.parameter1.ValueSet.Add(this.valueset);
            // **********************************************************************

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

            Assert.AreEqual("pt1", row.Name);
            Assert.IsTrue(row.Value.Contains("manual"));
            Assert.IsTrue(row.IsPublishable);
            Assert.IsNull(row.StateDependence);
            Assert.IsNull(row.MeasurementScale);
            Assert.AreEqual(0, row.ContainedRows.Count);
            Assert.AreEqual("domain", row.OwnerName);
            Assert.AreEqual("dom", row.OwnerShortName);

            this.parameterType1.Name           = "updatept1";
            this.parameterType1.RevisionNumber = 100;

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

            Assert.AreEqual("updatept1", row.Name);
        }
Exemplo n.º 4
0
        public void VerifyThatValueSetInlineEditWorksSimpleNoOptionState()
        {
            this.parameter.IsOptionDependent = false;
            this.parameter.StateDependence   = this.stateList;
            var set1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ActualState = this.actualState1
            };
            var set2 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ActualState = this.actualState2
            };

            this.parameter.ValueSet.Add(set1);
            this.parameter.ValueSet.Add(set2);

            var row = new ParameterRowViewModel(this.parameter, this.session.Object, null, false);

            var option1Row =
                row.ContainedRows.OfType <ParameterStateRowViewModel>().Single(x => x.ActualState == this.actualState1);

            option1Row.Switch = ParameterSwitchKind.REFERENCE;
            option1Row.CreateCloneAndWrite(ParameterSwitchKind.REFERENCE, "Switch");

            this.session.Verify(x => x.Write(It.Is <OperationContainer>(op => ((CDP4Common.DTO.ParameterValueSet)op.Operations.Single().ModifiedThing).ValueSwitch == ParameterSwitchKind.REFERENCE)));
        }
Exemplo n.º 5
0
        public void VerifyThatStateDependentPArameterAreSet()
        {
            var valueSetState1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var valueSetState2 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.SetScalarValueSet(valueSetState1);
            this.SetScalarValueSet(valueSetState2);

            valueSetState1.ActualState = this.stateList.ActualState.First();

            this.parameter1.ValueSet.Add(valueSetState1);
            this.parameter1.ValueSet.Add(valueSetState2);

            this.parameter1.StateDependence = this.stateList;
            var row = new ParameterRowViewModel(this.parameter1, this.session.Object, null, false);

            Assert.AreEqual(1, row.ContainedRows.Count);
            var firstState = (ParameterStateRowViewModel)row.ContainedRows.First();

            Assert.AreEqual("state1", firstState.Name);
            Assert.AreEqual("active", firstState.OwnerName);
            Assert.AreEqual("manual", firstState.Manual);
            Assert.AreEqual("computed", firstState.Computed);
            Assert.AreEqual("formula", firstState.Formula);
            Assert.AreEqual("ref", firstState.Reference);
            Assert.That(firstState.ScaleName, Is.Null.Or.Empty);
        }
Exemplo n.º 6
0
        public void VerifyThatTheSwitchIsUpdatedWhenContainerRowIsAParameterValueBaseRowViewModel()
        {
            var parameter             = new Parameter(Guid.NewGuid(), this.cache, this.uri);
            var boolPt                = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri);
            var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri);
            var component1            = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = boolPt
            };
            var component2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = boolPt
            };

            compoundParameterType.Component.Add(component1);
            compoundParameterType.Component.Add(component2);
            parameter.ParameterType = compoundParameterType;

            this.elementDefinition.Parameter.Add(parameter);

            var parameterRowViewModel = new ParameterRowViewModel(parameter, this.session.Object, null);
            var component1row         = (ParameterComponentValueRowViewModel)parameterRowViewModel.ContainedRows.First();
            var component2row         = (ParameterComponentValueRowViewModel)parameterRowViewModel.ContainedRows.Last();

            component1row.Switch = ParameterSwitchKind.COMPUTED;

            Assert.AreEqual(ParameterSwitchKind.COMPUTED, component2row.Switch);
        }
Exemplo n.º 7
0
        public void VerifyThatGetPathWorks()
        {
            this.parameterRowViewModel = new ParameterRowViewModel(this.parameter1, this.option, this.session.Object, null);
            var row = new ParameterStateRowViewModel(this.parameter1, this.state1, this.session.Object, this.parameterRowViewModel);

            Assert.AreEqual(this.nestedParameterPath, row.GetPath());
        }
Exemplo n.º 8
0
        public void VerifyThatOptionPArameterIsSet()
        {
            // Test input
            var valueSetOption1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var valueSetOption2 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.SetScalarValueSet(valueSetOption1);
            valueSetOption1.ActualOption = this.option1;

            this.SetScalarValueSet(valueSetOption2);
            valueSetOption2.ActualOption = this.option2;

            this.parameter1.IsOptionDependent = true;
            this.parameter1.ValueSet.Add(valueSetOption1);
            this.parameter1.ValueSet.Add(valueSetOption2);
            // *******************

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

            Assert.AreEqual(2, row.ContainedRows.Count);
            var firstOption = (ParameterOptionRowViewModel)row.ContainedRows.First();

            Assert.AreEqual("option1", firstOption.Name);
            Assert.AreEqual("active", firstOption.OwnerName);
            Assert.AreEqual("manual", firstOption.Manual);
            Assert.AreEqual("computed", firstOption.Computed);
            Assert.AreEqual("formula", firstOption.Formula);
            Assert.AreEqual("ref", firstOption.Reference);
            Assert.That(firstOption.ScaleName, Is.Null.Or.Empty);
        }
Exemplo n.º 9
0
        public void VerifyThatStateDependentRowAreUpdated()
        {
            var valueSetState1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var valueSetState2 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.SetScalarValueSet(valueSetState1);
            this.SetScalarValueSet(valueSetState2);

            var astate1 = this.stateList.ActualState.First();
            var astate2 = this.stateList.ActualState.Last();

            valueSetState1.ActualState = astate1;
            valueSetState2.ActualState = astate2;

            this.parameter1.ValueSet.Add(valueSetState1);
            this.parameter1.ValueSet.Add(valueSetState2);

            this.parameter1.StateDependence = this.stateList;
            var row = new ParameterRowViewModel(this.parameter1, this.session.Object, null, false);

            Assert.AreEqual(1, row.ContainedRows.Count);

            astate1.Kind = ActualFiniteStateKind.FORBIDDEN;
            CDPMessageBus.Current.SendObjectChangeEvent(astate1, EventKind.Updated);

            Assert.AreEqual(0, row.ContainedRows.Count);

            astate1.Kind = ActualFiniteStateKind.MANDATORY;
            CDPMessageBus.Current.SendObjectChangeEvent(astate1, EventKind.Updated);
            Assert.AreEqual(1, row.ContainedRows.Count);
        }
Exemplo n.º 10
0
        public void VerifyThatParameterCanBeDropped()
        {
            var row = new ParameterRowViewModel(this.cptParameter, this.session.Object, null, false);

            var group1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var group2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.assembler.Cache.TryAdd(new CacheKey(group1.Iid, this.iteration.Iid), new Lazy <Thing>(() => group1));
            this.assembler.Cache.TryAdd(new CacheKey(group2.Iid, this.iteration.Iid), new Lazy <Thing>(() => group2));

            this.elementDefinitionForUsage1.ParameterGroup.Add(group1);
            this.elementDefinitionForUsage1.ParameterGroup.Add(group2);

            this.cptParameter.Group = group1;
            group2.ContainingGroup  = group1;

            this.parameter.Group = null;

            var dropinfo = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Payload).Returns(this.parameter);
            dropinfo.SetupProperty(x => x.Effects);

            row.DragOver(dropinfo.Object);

            Assert.AreEqual(DragDropEffects.Move, dropinfo.Object.Effects);

            row.Drop(dropinfo.Object);
            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Once);
        }
Exemplo n.º 11
0
        public void VerifyThatStateDependentCompoundParameterCanBeSet()
        {
            var valueSetState1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.SetCompoundValueSet(valueSetState1);

            valueSetState1.ActualState = this.stateList.ActualState.First();

            this.parameterCompound.ValueSet.Add(valueSetState1);

            this.parameterCompound.StateDependence = this.stateList;
            var row = new ParameterRowViewModel(this.parameterCompound, this.session.Object, null, false);

            Assert.AreEqual("APTName", row.Name);
            Assert.AreEqual(1, row.ContainedRows.Count);

            var firstState = (ParameterStateRowViewModel)row.ContainedRows.First();

            Assert.AreEqual("state1", firstState.Name);
            Assert.AreEqual(2, firstState.ContainedRows.Count);

            var c2Row = (ParameterComponentValueRowViewModel)firstState.ContainedRows.Last();

            Assert.AreEqual("c2", c2Row.Name);
            Assert.AreEqual("other", c2Row.OwnerName);
            Assert.AreEqual("manual2", c2Row.Manual);
            Assert.AreEqual("computed2", c2Row.Computed);
            Assert.AreEqual("formula2", c2Row.Formula);
            Assert.AreEqual("ref2", c2Row.Reference);
            Assert.That(c2Row.ScaleName, Is.Null.Or.Empty);
        }
        public void VerifyThatOwnerIsUpdatedForParameterOrOverride(IViewModelBase <Thing> container, string scenario)
        {
            var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri);

            parameter.Owner = this.activeDomain;
            var boolPt = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri);
            var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri);
            var component1            = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = boolPt
            };
            var component2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = boolPt
            };

            compoundParameterType.Component.Add(component1);
            compoundParameterType.Component.Add(component2);
            parameter.ParameterType = compoundParameterType;
            this.elementDefinition.Parameter.Add(parameter);

            var parameterSubscriptionRowViewModel = new ParameterRowViewModel(parameter, this.session.Object, container, false);

            var component1row = (ParameterComponentValueRowViewModel)parameterSubscriptionRowViewModel.ContainedRows.First();

            Assert.IsTrue(component1row.OwnerName.Contains(this.activeDomain.Name));

            this.activeDomain.Name           = "updated";
            this.activeDomain.RevisionNumber = 100;
            CDPMessageBus.Current.SendObjectChangeEvent(this.activeDomain, EventKind.Updated);

            Assert.IsTrue(component1row.OwnerName.Contains("updated"));
        }
Exemplo n.º 13
0
        public void VerifyThatOnUpdateOfStateTheRowIsUpdated(IViewModelBase <Thing> container, string scenario)
        {
            // **************************INPUT***************************************
            var published = new ValueArray <string>(new List <string> {
                "manual"
            }, this.valueset);
            var actual = new ValueArray <string>(new List <string> {
                "different"
            }, this.valueset);

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

            this.parameter1.ValueSet.Add(this.valueset);
            this.parameter1.IsOptionDependent = true;
            this.parameter1.StateDependence   = this.stateList;

            var valueset2 = new ParameterValueSet(Guid.NewGuid(), null, this.uri);

            this.parameter1.ValueSet.Add(valueset2);

            // **********************************************************************

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

            Assert.AreEqual(1, row.ContainedRows.Count);
            this.state1.Kind = ActualFiniteStateKind.FORBIDDEN;
            CDPMessageBus.Current.SendObjectChangeEvent(this.state1, EventKind.Updated);
            Assert.AreEqual(0, row.ContainedRows.Count);
        }
Exemplo n.º 14
0
        public void VerifyCreateParameterOverride()
        {
            var vm             = new ProductTreeViewModel(this.option, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, this.dialogNavigationService.Object, null);
            var revisionNumber = typeof(Iteration).GetProperty("RevisionNumber");

            revisionNumber.SetValue(this.iteration, 50);
            var elementdef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Container = this.iteration
            };
            var boolParamType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var elementUsage  = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Container         = elementdef,
                ElementDefinition = elementdef
            };
            var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = this.domain, Container = elementUsage, ParameterType = boolParamType
            };

            elementdef.Parameter.Add(parameter);
            var published = new ValueArray <string>(new List <string> {
                "published"
            });
            var paramValueSet = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Published   = published,
                Manual      = published,
                Computed    = published,
                ValueSwitch = ParameterSwitchKind.COMPUTED
            };

            parameter.ValueSet.Add(paramValueSet);

            var usageRow     = new ElementUsageRowViewModel(elementUsage, this.option, this.session.Object, null);
            var parameterRow = new ParameterRowViewModel(parameter, this.option, this.session.Object, usageRow);

            this.iteration.TopElement = elementdef;
            vm.SelectedThing          = parameterRow;

            Assert.IsTrue(vm.CreateOverrideCommand.CanExecute(null));

            vm.SelectedThing = null;
            vm.CreateOverrideCommand.Execute(null);
            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Never);

            vm.SelectedThing = vm.TopElement.Single();
            vm.CreateOverrideCommand.Execute(null);
            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Never);

            vm.SelectedThing = parameterRow;
            vm.CreateOverrideCommand.Execute(parameter);
            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));

            vm.PopulateContextMenu();
            Assert.AreEqual(6, vm.ContextMenu.Count);
        }
Exemplo n.º 15
0
        public void VerifyThatPropertiesAreSet()
        {
            this.parameterRowViewModel = new ParameterRowViewModel(this.parameter1, this.option, this.session.Object, null);
            var row = new ParameterStateRowViewModel(this.parameter1, this.state1, this.session.Object, this.parameterRowViewModel);

            Assert.AreEqual(row.ActualState, this.state1);
            Assert.AreEqual(row.IsDefault, row.ActualState.IsDefault);
            Assert.AreSame(this.state1.Name, row.ActualState.Name);
        }
Exemplo n.º 16
0
        public void VerifyThatValidatePropertyWorks()
        {
            this.parameter1.ParameterType = this.boolPt;
            var row = new ParameterRowViewModel(this.parameter1, this.session.Object, null, false);

            Assert.That(row.ValidateProperty("Manual", "12,45"), Is.Not.Null.Or.Empty);
            Assert.That(row.ValidateProperty("Reference", "12,45"), Is.Not.Null.Or.Empty);
            Assert.That(row.ValidateProperty("Manual", true), Is.Null.Or.Empty);
            Assert.That(row.ValidateProperty("Reference", null), Is.Null.Or.Empty);
        }
        public void VerifyCreateParameterOverride()
        {
            var browser      = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, this.panelNavigationService.Object, null, null, null, null);
            var elementUsage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = this.elementDef.Owner, ElementDefinition = this.elementDef, Container = this.elementDef
            };
            var usageRow  = new ElementUsageRowViewModel(elementUsage, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object);
            var qk        = new SimpleQuantityKind();
            var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Container     = this.elementDef,
                ParameterType = qk,
                Owner         = this.elementDef.Owner
            };

            var parameterRow = new ParameterRowViewModel(parameter, this.session.Object, usageRow, false);

            Assert.IsFalse(browser.CreateOverrideCommand.CanExecute(null));
            browser.SelectedThing = parameterRow;
            Assert.IsTrue(browser.CreateOverrideCommand.CanExecute(null));
            browser.CreateOverrideCommand.Execute(parameter);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()));

            browser.SelectedThing = null;
            browser.ComputePermission();
            browser.CreateOverrideCommand.Execute(null);
            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Once);

            var paramtType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);

            paramtType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri), Scale = null
            });
            parameter.ParameterType = paramtType;

            var elementDefRow         = new ElementDefinitionRowViewModel(this.elementDef, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object);
            var parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameter, 0, this.session.Object, null, null, elementDefRow, false);

            browser.SelectedThing = parameterValueBaseRow;
            browser.ComputePermission();
            browser.CreateOverrideCommand.Execute(null);

            var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Parameter = parameter, Owner = this.elementDef.Owner
            };

            parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameterOverride, 0, this.session.Object, null, null, usageRow, false);
            browser.SelectedThing = parameterValueBaseRow;
            browser.CreateOverrideCommand.Execute(null);
        }
Exemplo n.º 18
0
        public void VerifyThatDragOverWorksCorrectlyForNotSupportedType()
        {
            var vm = new ParameterRowViewModel(this.parameter, this.session.Object, null, false);

            var dropinfo = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Payload).Returns(this.person);

            dropinfo.SetupProperty(x => x.Effects);
            vm.DragOver(dropinfo.Object);

            Assert.AreEqual(DragDropEffects.None, dropinfo.Object.Effects);
        }
Exemplo n.º 19
0
        public void VerifyThatDragOverWorksForRelationalExpression()
        {
            var vm = new ParameterRowViewModel(this.parameter, this.session.Object, null, false);

            var dropinfo = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Payload).Returns(this.relationalExpression);

            dropinfo.SetupProperty(x => x.Effects);
            vm.DragOver(dropinfo.Object);

            Assert.AreEqual(DragDropEffects.Copy, dropinfo.Object.Effects);
        }
Exemplo n.º 20
0
        public void VerifyThatDropWorksCorrectlyForNotSupportedType()
        {
            var vm = new ParameterRowViewModel(this.parameter, this.session.Object, null, false);

            var dropinfo = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Payload).Returns(this.parameter);

            dropinfo.SetupProperty(x => x.Effects);
            vm.DragOver(dropinfo.Object);

            this.thingCreator.Verify(x => x.CreateBinaryRelationshipForRequirementVerification(It.IsAny <ISession>(), It.IsAny <Iteration>(), It.IsAny <ParameterOrOverrideBase>(), It.IsAny <RelationalExpression>()), Times.Never);
        }
Exemplo n.º 21
0
        public void VerifyThatParameterComponentRowsUpdateOnParameterTypeUpdate()
        {
            var row = new ParameterRowViewModel(this.parameterCompound, this.session.Object, null, false);

            Assert.AreEqual(2, this.cptType.Component.Count);
            Assert.AreEqual(2, row.ContainedRows.Count);

            this.cptType.Component.Remove(this.cptType.Component.Last());
            Assert.AreEqual(1, this.cptType.Component.Count);

            CDPMessageBus.Current.SendObjectChangeEvent(this.cptType, EventKind.Updated);
            Assert.AreEqual(1, row.ContainedRows.Count);
        }
Exemplo n.º 22
0
        public void VerifyThatCategoryIsCollectedCorrectlyForElementDefinition()
        {
            var elementDefinitionRow = new ElementDefinitionRowViewModel(this.elementdef1, this.option, this.session.Object, null);
            var row = new ParameterRowViewModel(this.parameter1, this.option, this.session.Object, elementDefinitionRow);

            Assert.AreEqual(1, row.Category.Count());

            var expectedCategories = new List <Category>
            {
                this.category1
            };

            CollectionAssert.AreEquivalent(expectedCategories, row.Category);
        }
Exemplo n.º 23
0
        public void VerifyThatStartDragWithPermissionWorks()
        {
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            var row = new ParameterRowViewModel(this.cptParameter, this.session.Object, null, false);

            var draginfo = new Mock <IDragInfo>();

            draginfo.SetupProperty(x => x.Payload);
            draginfo.SetupProperty(x => x.Effects);
            row.StartDrag(draginfo.Object);

            Assert.AreEqual(DragDropEffects.All, draginfo.Object.Effects);
            Assert.AreSame(this.cptParameter, draginfo.Object.Payload);
        }
Exemplo n.º 24
0
        public async Task VerifyThatDropWorksForRelationalExpression()
        {
            var vm = new ParameterRowViewModel(this.parameter, this.session.Object, null, false);

            var dropinfo = new Mock <IDropInfo>();

            dropinfo.Setup(x => x.Payload).Returns(this.relationalExpression);
            dropinfo.Setup(x => x.Effects).Returns(DragDropEffects.Copy);

            dropinfo.SetupProperty(x => x.Effects);
            await vm.Drop(dropinfo.Object);

            this.thingCreator.Verify(x => x.CreateBinaryRelationshipForRequirementVerification(It.IsAny <ISession>(), It.IsAny <Iteration>(), It.IsAny <ParameterOrOverrideBase>(), It.IsAny <RelationalExpression>()), Times.Once);
        }
Exemplo n.º 25
0
        public void VerifyThatCategoryIsCollectedCorrectlyForElementDefinition()
        {
            var elementDefinitionRow = new ElementDefinitionRowViewModel(this.elementDefinition, this.activeDomain, this.session.Object, null, this.obfuscationService.Object);
            var row = new ParameterRowViewModel(this.parameter1, this.session.Object, elementDefinitionRow, false);

            Assert.AreEqual(2, row.Category.Count());

            var expectedCategories = new List <Category>
            {
                this.category1,
                this.category2
            };

            CollectionAssert.AreEquivalent(expectedCategories, row.Category);
        }
Exemplo n.º 26
0
        public void VerifyThatPropertiesArePopulatedForScalarStateDependent(IViewModelBase <Thing> container, string scenario)
        {
            // **************************INPUT***************************************
            var published = new ValueArray <string>(new List <string> {
                "manual"
            }, this.valueset);
            var actual = new ValueArray <string>(new List <string> {
                "different"
            }, this.valueset);

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

            this.parameter1.ValueSet.Add(this.valueset);
            this.parameter1.IsOptionDependent = true;
            this.parameter1.StateDependence   = this.stateList;

            var valueset2 = new ParameterValueSet(Guid.NewGuid(), null, this.uri);

            this.parameter1.ValueSet.Add(valueset2);

            // **********************************************************************

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

            Assert.IsTrue(row.IsPublishable);
            Assert.That(row.Value, Is.Null.Or.Empty);
            Assert.IsNotNull(row.StateDependence);
            Assert.IsNull(row.MeasurementScale);
            Assert.AreEqual(1, row.ContainedRows.Count);

            var staterow = row.ContainedRows.OfType <ParameterStateRowViewModel>().Single();

            Assert.IsTrue(staterow.Value.Contains("manual"));
            Assert.IsTrue(staterow.IsPublishable);

            // update publish value and check that isPublishable is false
            this.valueset.Manual         = published;
            this.valueset.RevisionNumber = 10;
            CDPMessageBus.Current.SendObjectChangeEvent(this.valueset, EventKind.Updated);
            Assert.IsFalse(row.IsPublishable);

            Assert.AreEqual("domain", row.OwnerName);
            Assert.AreEqual("dom", row.OwnerShortName);
        }
Exemplo n.º 27
0
        public void VerifyThatOptionStateDependentCompoundParameterCanBeSet()
        {
            var valueSeto1s1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var valueSeto2s1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.SetCompoundValueSet(valueSeto1s1);
            this.SetCompoundValueSet(valueSeto2s1);

            valueSeto1s1.ActualOption = this.option1;
            valueSeto1s1.ActualState  = this.stateList.ActualState.First();

            valueSeto2s1.ActualOption = this.option2;
            valueSeto2s1.ActualState  = this.stateList.ActualState.First();

            this.parameterCompound.ValueSet.Add(valueSeto1s1);
            this.parameterCompound.ValueSet.Add(valueSeto2s1);

            this.parameterCompound.IsOptionDependent = true;
            this.parameterCompound.StateDependence   = this.stateList;

            // Test starts
            var row = new ParameterRowViewModel(this.parameterCompound, this.session.Object, null, false);

            Assert.AreEqual("APTName", row.Name);
            Assert.AreEqual(2, row.ContainedRows.Count);

            var o2row = (ParameterOptionRowViewModel)row.ContainedRows.Last();

            Assert.AreEqual("option2", o2row.Name);
            Assert.IsNull(o2row.Manual);
            Assert.AreEqual(1, o2row.ContainedRows.Count);

            var stateRow = (ParameterStateRowViewModel)o2row.ContainedRows.Single();

            Assert.AreEqual("state1", stateRow.Name);
            Assert.AreEqual(2, stateRow.ContainedRows.Count);
            Assert.IsNull(stateRow.Manual);

            var c2row = (ParameterComponentValueRowViewModel)stateRow.ContainedRows.Last();

            Assert.AreEqual("c2", c2row.Name);
            Assert.AreEqual("other", c2row.OwnerName);
            Assert.AreEqual("manual2", c2row.Manual);
            Assert.AreEqual("computed2", c2row.Computed);
            Assert.AreEqual("formula2", c2row.Formula);
            Assert.AreEqual("ref2", c2row.Reference);
            Assert.That(c2row.ScaleName, Is.Null.Or.Empty);
        }
Exemplo n.º 28
0
        public void VerifyThatValueSetInlineEditWorksCompoundOptionState()
        {
            var row        = new ParameterRowViewModel(this.cptParameter, this.session.Object, null, false);
            var option1Row =
                row.ContainedRows.OfType <ParameterOptionRowViewModel>().Single(x => x.ActualOption == this.option1);

            var o1s1Row = option1Row.ContainedRows.OfType <ParameterStateRowViewModel>()
                          .Single(x => x.ActualState == this.actualState1);

            var o1s1c1Row = o1s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First();

            o1s1c1Row.Switch = ParameterSwitchKind.REFERENCE;
            o1s1c1Row.CreateCloneAndWrite(ParameterSwitchKind.REFERENCE, "Switch");

            this.session.Verify(x => x.Write(It.Is <OperationContainer>(op => ((CDP4Common.DTO.ParameterValueSet)op.Operations.Single().ModifiedThing).ValueSwitch == ParameterSwitchKind.REFERENCE)));
        }
        public void VerifyThatRowsAreInsertedCorrectly()
        {
            var list     = new ReactiveList <IRowViewModelBase <Thing> >();
            var comparer = new ParameterGroupChildRowComparer();

            var parameter1 = new Parameter(Guid.NewGuid(), null, this.uri)
            {
                ParameterType = this.type, Owner = this.domain, Container = this.elementDef
            };

            parameter1.ValueSet.Add(this.valueSet);

            var subscription = new ParameterSubscription(Guid.NewGuid(), null, this.uri);

            parameter1.ParameterSubscription.Add(subscription);

            var parameterRow1 = new ParameterRowViewModel(parameter1, this.session.Object, null, false);

            var group1 = new ParameterGroup(Guid.NewGuid(), null, this.uri)
            {
                Name = "a"
            };
            var groupRow1 = new ParameterGroupRowViewModel(group1, this.domain, this.session.Object, null);

            var group2 = new ParameterGroup(Guid.NewGuid(), null, this.uri)
            {
                Name = "b"
            };
            var groupRow2 = new ParameterGroupRowViewModel(group2, this.domain, this.session.Object, null);

            var subscriptionRow = new ParameterSubscriptionRowViewModel(subscription, this.session.Object, null, false);

            list.SortedInsert(parameterRow1, comparer);
            list.SortedInsert(groupRow1, comparer);
            list.SortedInsert(groupRow2, comparer);
            list.SortedInsert(subscriptionRow, comparer);

            Assert.AreSame(subscriptionRow, list[0]);
            Assert.AreSame(parameterRow1, list[1]);
            Assert.AreSame(groupRow1, list[2]);
            Assert.AreSame(groupRow2, list[3]);
        }
Exemplo n.º 30
0
        public void VerifyThatNoOptionNoStateParameterIsSet()
        {
            // Test input
            var valueSet = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.SetScalarValueSet(valueSet);

            this.parameter1.ValueSet.Add(valueSet);
            // *******************

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

            Assert.AreEqual("PTName", row.Name);
            Assert.AreEqual("active", row.OwnerName);
            Assert.AreEqual("manual", row.Manual);
            Assert.AreEqual("computed", row.Computed);
            Assert.AreEqual("ref", row.Reference);
            Assert.AreEqual("formula", row.Formula);
            Assert.That(row.ScaleName, Is.Null.Or.Empty);
        }