public void VerifyThatWrongParameterValueDisableOkButton()
        {
            this.parameter.ParameterType = this.simpleQt;
            this.parameter.Scale         = this.integerScale;
            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            var row = vm.ValueSet.Single();

            row.Manual = "100";
            var error = row["Manual"];

            Assert.IsTrue(vm.ValidationErrors.Any(x => x.PropertyName == "Manual"));
            Assert.IsFalse(vm.OkCanExecute);

            row.Manual = "2";
            error      = row["Manual"];

            Assert.IsFalse(vm.ValidationErrors.Any(x => x.PropertyName == "Manual"));
            Assert.IsTrue(vm.OkCanExecute);

            row.Reference = "100";
            error         = row["Reference"];

            Assert.IsTrue(vm.ValidationErrors.Any(x => x.PropertyName == "Reference"));
            Assert.IsFalse(vm.OkCanExecute);

            row.Reference = "2";
            error         = row["Reference"];

            Assert.IsFalse(vm.ValidationErrors.Any(x => x.PropertyName == "Reference"));
            Assert.IsTrue(vm.OkCanExecute);
        }
        public void VerifyThatWrongParameterOptionValueDisableOkButton()
        {
            var defaultList = new List <string> {
                "-"
            };

            this.parameter.ParameterType     = this.simpleQt;
            this.parameter.Scale             = this.integerScale;
            this.parameter.IsOptionDependent = true;

            this.parameter.ValueSet.Clear();
            var v1 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri)
            {
                ActualOption = this.option1
            };

            this.PopulateValueSet(v1, defaultList);

            var v2 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri)
            {
                ActualOption = this.option2
            };

            this.PopulateValueSet(v2, defaultList);

            this.parameter.ValueSet.Add(v1);
            this.parameter.ValueSet.Add(v2);

            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            var row = vm.ValueSet.Single();

            var o1 = (ParameterOptionRowViewModel)row.ContainedRows.First();

            o1.Manual = "100";
            var error = o1["Manual"];

            Assert.IsTrue(vm.ValidationErrors.Any(x => x.PropertyName == "o1..0Manual"));
            Assert.IsFalse(vm.OkCanExecute);

            o1.Manual = "2";
            error     = o1["Manual"];

            Assert.IsFalse(vm.ValidationErrors.Any(x => x.PropertyName == "o1..0Manual"));
            Assert.IsTrue(vm.OkCanExecute);

            o1.Reference = "100";
            error        = o1["Reference"];

            Assert.IsTrue(vm.ValidationErrors.Any(x => x.PropertyName == "o1..0Reference"));
            Assert.IsFalse(vm.OkCanExecute);

            o1.Reference = "2";
            error        = o1["Reference"];

            Assert.IsFalse(vm.ValidationErrors.Any(x => x.PropertyName == "o1..0Reference"));
            Assert.IsTrue(vm.OkCanExecute);
        }
        public void VerifyUpdateOkExecute()
        {
            this.parameter.Scale = this.integerScale;
            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true,
                                                  ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            Assert.IsTrue(vm.OkCommand.CanExecute(null));
            vm.OkCommand.Execute(null);
        }
        public void VerifyInspectStateDependence()
        {
            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true,
                                                  ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            Assert.IsNull(vm.SelectedStateDependence);

            vm.SelectedStateDependence = vm.PossibleStateDependence.First();
            Assert.IsTrue(vm.InspectSelectedStateDependenceCommand.CanExecute(null));
            vm.InspectSelectedStateDependenceCommand.Execute(null);
            this.thingDialogNavigationService.Verify(x => x.Navigate(It.IsAny <ActualFiniteStateList>(), It.IsAny <ThingTransaction>(), this.session.Object, false, ThingDialogKind.Inspect, this.thingDialogNavigationService.Object, It.IsAny <Thing>(), null));
        }
        public void Verify_that_when_parameterType_is_not_QuantityKind_the_scale_must_be_null()
        {
            var textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);

            this.parameter.ParameterType = textParameterType;
            this.parameter.Scale         = null;

            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true,
                                                  ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

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

            vm.SelectedScale = this.integerScale;

            Assert.IsFalse(vm.OkCommand.CanExecute(null));
        }
        public void VerifyThatWrongParameterStateValueDisableOkButtonWhenScaleChanges()
        {
            var defaultList = new List <string> {
                "-"
            };

            this.parameter.ParameterType     = this.simpleQt;
            this.parameter.Scale             = this.realScale;
            this.parameter.IsOptionDependent = false;
            this.parameter.StateDependence   = this.asl;

            this.parameter.ValueSet.Clear();
            var v1 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri)
            {
                ActualState = this.as1
            };

            this.PopulateValueSet(v1, defaultList);

            var v2 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri)
            {
                ActualState = this.as2
            };

            this.PopulateValueSet(v2, defaultList);

            this.parameter.ValueSet.Add(v1);
            this.parameter.ValueSet.Add(v2);

            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            var row = vm.ValueSet.Single();

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

            s1.Manual = "5.12";
            var error = s1["Manual"];

            Assert.IsFalse(vm.ValidationErrors.Any(x => x.PropertyName == ".1.0Manual"));
            Assert.IsTrue(vm.OkCanExecute);

            vm.SelectedScale = this.integerScale;
            error            = s1["Manual"];

            Assert.IsTrue(vm.ValidationErrors.Any(x => x.PropertyName == ".1.0Manual"));
            Assert.IsFalse(vm.OkCanExecute);
        }
        public void VerifyThatMakingOptionOrStateDependentSetToFalse()
        {
            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true,
                                                  ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            Assert.IsTrue(vm.IsValueSetEditable);

            vm.IsOptionDependent = true;
            Assert.IsFalse(vm.IsValueSetEditable);

            vm.SelectedStateDependence = vm.PossibleStateDependence.First();
            Assert.IsFalse(vm.IsValueSetEditable);

            vm.IsOptionDependent = false;
            Assert.IsFalse(vm.IsValueSetEditable);

            vm.SelectedStateDependence = null;
            Assert.IsTrue(vm.IsValueSetEditable);
        }
        public void VerifyThatWrongParameterComponentValueDisableOkButton()
        {
            var defaultList = new List <string> {
                "-"
            };

            this.parameter.ParameterType     = this.cptPt;
            this.parameter.IsOptionDependent = false;
            this.parameter.StateDependence   = null;

            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            var row = vm.ValueSet.Single();

            var c1 = (ParameterComponentValueRowViewModel)row.ContainedRows.First();

            c1.Manual = "5500000";
            var error = c1["Manual"];

            Assert.IsTrue(vm.ValidationErrors.Any(x => x.PropertyName == "..0Manual"));
            Assert.IsFalse(vm.OkCanExecute);

            c1.Manual = "4";
            error     = c1["Manual"];

            Assert.IsFalse(vm.ValidationErrors.Any(x => x.PropertyName == "..0Manual"));
            Assert.IsTrue(vm.OkCanExecute);

            c1.Reference = "100";
            error        = c1["Reference"];

            Assert.IsTrue(vm.ValidationErrors.Any(x => x.PropertyName == "..0Reference"));
            Assert.IsFalse(vm.OkCanExecute);

            c1.Reference = "2";
            error        = c1["Reference"];

            Assert.IsFalse(vm.ValidationErrors.Any(x => x.PropertyName == "..0Reference"));
            Assert.IsTrue(vm.OkCanExecute);
        }
        public void VerifyThatPropertiesArePopulated()
        {
            var vm = new ParameterDialogViewModel(this.parameter, this.thingTransaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, this.elementDefinitionClone);

            Assert.IsNotNull(vm.SelectedParameterType);
            Assert.IsNotNull(vm.SelectedOwner);
            Assert.AreEqual(1, vm.ValueSet.Count);
            Assert.AreEqual(3, vm.PossibleParameterType.Count);
            Assert.AreEqual(2, vm.PossibleOwner.Count);
            Assert.AreEqual(1, vm.PossibleRequestedBy.Count);
            Assert.AreEqual(1, vm.PossibleStateDependence.Count);
            Assert.AreEqual(1, vm.PossibleScale.Count);
            var valueSet = vm.ValueSet.First();

            Assert.AreEqual("m", valueSet.Manual);
            Assert.AreEqual("r", valueSet.Reference);
            Assert.AreEqual("c", valueSet.Computed);
            Assert.AreEqual(ParameterSwitchKind.COMPUTED, valueSet.Switch);
            Assert.AreEqual("c", valueSet.Value);

            Assert.AreEqual(1, vm.ParameterSubscription.Count);
        }
        public void VerifyThatParameterlessContructorExists()
        {
            var dialogViewModel = new ParameterDialogViewModel();

            Assert.IsFalse(dialogViewModel.IsReadOnly);
        }