Exemplo n.º 1
0
        public void VerifyThatPropertiesAreSet()
        {
            var constantName      = "constant1";
            var constantShortName = "c1";
            var constant          = new Constant(Guid.NewGuid(), null, this.uri)
            {
                Name = constantName, ShortName = constantShortName
            };
            var testParameterType = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri);
            var testScale         = new RatioScale(Guid.NewGuid(), null, this.uri);

            testParameterType.PossibleScale.Add(testScale);
            constant.ParameterType = testParameterType;
            constant.Value         = new ValueArray <string>(new List <string> {
                "1"
            });
            this.siteRdl.ParameterType.Add(testParameterType);
            this.siteRdl.ParameterType.Add(new BooleanParameterType(Guid.NewGuid(), null, this.uri));
            var vm = new ConstantDialogViewModel(constant, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object);

            Assert.AreEqual(2, vm.PossibleContainer.Count);
            vm.Container = vm.PossibleContainer.Last();
            Assert.AreEqual(constantName, vm.Name);
            Assert.AreEqual(constantShortName, vm.ShortName);
            Assert.AreEqual(2, vm.PossibleCategory.Count);
            Assert.AreEqual(2, vm.PossibleParameterType.Count);
            Assert.AreEqual(testParameterType, vm.SelectedParameterType);
            Assert.AreEqual(1, vm.PossibleScale.Count);
            Assert.AreEqual(testScale, vm.SelectedScale);
            Assert.IsNotNull(vm.Value);
            Assert.AreEqual(1, vm.Value.Count);
            Assert.AreEqual("1", vm.Value.First().Value);
        }
Exemplo n.º 2
0
        public void VerifyUpdateOkCanExecute()
        {
            var constantName      = "constant1";
            var constantShortName = "c1";
            var constant          = new Constant(Guid.NewGuid(), null, this.uri)
            {
                Name = constantName, ShortName = constantShortName
            };
            var testParameterType = new SimpleQuantityKind(Guid.NewGuid(), null, null);
            var testScale         = new RatioScale(Guid.NewGuid(), null, this.uri);

            testParameterType.PossibleScale.Add(testScale);
            constant.ParameterType = testParameterType;
            constant.Value         = new ValueArray <string>(new List <string> {
                "1"
            });
            this.siteRdl.ParameterType.Add(testParameterType);
            this.siteRdl.ParameterType.Add(new BooleanParameterType(Guid.NewGuid(), null, null));
            var vm = new ConstantDialogViewModel(constant, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object);

            Assert.IsTrue(vm.OkCanExecute);
            vm.SelectedParameterType = null;
            Assert.IsFalse(vm.OkCanExecute);
            vm.SelectedParameterType = testParameterType;
            Assert.IsTrue(vm.OkCanExecute);

            vm.Value.First().Value = string.Empty;
            Assert.IsFalse(vm.OkCanExecute);

            vm.Value.First().Value = "Not empty value";
            Assert.IsTrue(vm.OkCanExecute);
        }
Exemplo n.º 3
0
        public void VerifyThatContainerIsSetForConstantInspect()
        {
            var expectedContainers = new List <ReferenceDataLibrary>();

            expectedContainers.Add(this.siteRdl);

            var constant = new Constant(Guid.NewGuid(), null, this.uri);

            this.siteRdl.Constant.Add(constant);

            var vm = new ConstantDialogViewModel(constant, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.dialogService.Object, null);

            CollectionAssert.AreEquivalent(expectedContainers, vm.PossibleContainer);
        }
Exemplo n.º 4
0
        public void VerifyThatPermissionsForPossibleContainer()
        {
            var constantName      = "constant1";
            var constantShortName = "c1";
            var constant          = new Constant(Guid.NewGuid(), null, this.uri)
            {
                Name = constantName, ShortName = constantShortName
            };
            var testParameterType = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri);
            var testScale         = new RatioScale(Guid.NewGuid(), null, this.uri);

            testParameterType.PossibleScale.Add(testScale);
            constant.ParameterType = testParameterType;
            constant.Value         = new ValueArray <string>(new List <string> {
                "1"
            });
            this.siteRdl.ParameterType.Add(testParameterType);
            this.siteRdl.ParameterType.Add(new BooleanParameterType(Guid.NewGuid(), null, this.uri));
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <SiteReferenceDataLibrary>())).Returns(false);
            var vm = new ConstantDialogViewModel(constant, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object);

            Assert.AreEqual(0, vm.PossibleContainer.Count);
        }