Beispiel #1
0
        public void VerifyContextMenuPopulation()
        {
            var vm = new ProductTreeViewModel(this.option, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, this.dialogNavigationService.Object, null);

            Assert.AreEqual(0, vm.ContextMenu.Count);
            Assert.IsNull(vm.SelectedThing);
            vm.PopulateContextMenu();
            Assert.AreEqual(0, vm.ContextMenu.Count);

            var elemDef = vm.TopElement.Single();

            vm.SelectedThing = elemDef;
            vm.PopulateContextMenu();
            Assert.AreEqual(5, vm.ContextMenu.Count);
        }
Beispiel #2
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);
        }
        public void VerifyExecuteDeleteSubscriptionCommand()
        {
            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 anotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "Not owned"
            };
            var boolParamType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var parameter     = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = anotherDomain, Container = elementdef, ParameterType = boolParamType
            };

            parameter.ParameterSubscription.Add(new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = this.domain
            });
            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);
            elementdef.Parameter.Add(parameter);
            this.iteration.TopElement = elementdef;

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated);
            Assert.AreSame(elementdef, vm.TopElement.Single().Thing);
            Assert.AreEqual(1, vm.TopElement.Single().ContainedRows.Count);
            var paramRow = vm.TopElement.Single().ContainedRows.First() as ParameterOrOverrideBaseRowViewModel;

            Assert.NotNull(paramRow);
            vm.SelectedThing = paramRow;

            vm.PopulateContextMenu();
            Assert.AreEqual(8, vm.ContextMenu.Count);

            Assert.IsTrue(vm.DeleteSubscriptionCommand.CanExecute(null));
            Assert.AreEqual(1, paramRow.Thing.ParameterSubscription.Count);
            vm.DeleteSubscriptionCommand.Execute(null);
        }
        public void VerifyCopyPathToClipboardCommand()
        {
            var elementdef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Container = this.iteration, ShortName = "ELEMENT"
            };
            var anotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "Not owned"
            };
            var boolParamType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ShortName = "PARAM"
            };
            var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = anotherDomain, Container = elementdef, ParameterType = boolParamType
            };
            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);
            elementdef.Parameter.Add(parameter);
            this.iteration.TopElement = elementdef;

            var vm = new ProductTreeViewModel(this.option, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, this.dialogNavigationService.Object, null);

            var paramRow = vm.TopElement.Single().ContainedRows.First() as ParameterOrOverrideBaseRowViewModel;

            Assert.NotNull(paramRow);
            vm.SelectedThing = paramRow;

            vm.PopulateContextMenu();
            Assert.AreEqual(7, vm.ContextMenu.Count);

            Clipboard.SetText("Reset");

            vm.CopyPathToClipboardCommand.Execute(null);

            Assert.IsTrue(Clipboard.GetDataObject().GetData(typeof(string)).ToString().Contains($"{this.nestedParameterPath}"));
        }