Example #1
0
        public void VerifyThatNewParameterTypeDragOverSetsCopyEffect()
        {
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);

            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.Owner = domainOfExpertise;
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.ParameterGroup.Add(parameterGroup);

            this.iteration.Element.Add(elementDefinition);

            var row = new ParameterGroupRowViewModel(parameterGroup, domainOfExpertise, this.session.Object, null);

            var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ratioScale         = new RatioScale(Guid.NewGuid(), null, null);

            simpleQuantityKind.DefaultScale = ratioScale;
            this.srdl.ParameterType.Add(simpleQuantityKind);

            var payload  = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale);
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(payload);
            dropInfo.SetupProperty(x => x.Effects);

            row.DragOver(dropInfo.Object);

            Assert.AreEqual(DragDropEffects.Copy, dropInfo.Object.Effects);
        }
Example #2
0
        public void Verify_that_when_referenced_MeasurementScale_is_not_in_chain_of_rdls_result_is_returned()
        {
            var scale = new RatioScale {
                Iid = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"), ShortName = "SCALE"
            };
            var otherSiterReferenceDataLibrary = new SiteReferenceDataLibrary();

            otherSiterReferenceDataLibrary.Scale.Add(scale);

            this.simpleQuantityKind.PossibleScale.Add(scale);
            this.simpleQuantityKind.DefaultScale = scale;

            var first = this.quantityKindRuleChecker.CheckWhetherReferencedMeasurementScaleInChainOfRdls(this.simpleQuantityKind).First();
            var last  = this.quantityKindRuleChecker.CheckWhetherReferencedMeasurementScaleInChainOfRdls(this.simpleQuantityKind).Last();

            Assert.That(first.Id, Is.EqualTo("MA-0230"));
            Assert.That(first.Description, Is.EqualTo("The referenced MeasurementScale 1191838a-0f9f-4d2c-8369-cf729d281dee:SCALE in QuantityKind.PossibleScale is not in the chain of Reference Data Libraries"));
            Assert.That(first.Thing, Is.EqualTo(this.simpleQuantityKind));
            Assert.That(first.Severity, Is.EqualTo(SeverityKind.Error));

            Assert.That(last.Id, Is.EqualTo("MA-0230"));
            Assert.That(last.Description, Is.EqualTo("The referenced MeasurementScale 1191838a-0f9f-4d2c-8369-cf729d281dee:SCALE in QuantityKind.DefaultScale is not in the chain of Reference Data Libraries"));
            Assert.That(last.Thing, Is.EqualTo(this.simpleQuantityKind));
            Assert.That(last.Severity, Is.EqualTo(SeverityKind.Error));
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
0
        public void Verify_that_when_referenced_DeprecatableThing_Is_Deprecated_result_is_returned()
        {
            var scale = new RatioScale
            {
                Iid          = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"),
                ShortName    = "SCALE",
                IsDeprecated = true
            };

            this.simpleQuantityKind.PossibleScale.Add(scale);
            this.simpleQuantityKind.DefaultScale = scale;

            var results = this.quantityKindRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.simpleQuantityKind);

            var first = results.First();

            Assert.That(first.Id, Is.EqualTo("MA-0500"));
            Assert.That(first.Description, Is.EqualTo("The referenced MeasurementScale 1191838a-0f9f-4d2c-8369-cf729d281dee:SCALE in QuantityKind.PossibleScale is deprecated"));
            Assert.That(first.Thing, Is.EqualTo(this.simpleQuantityKind));
            Assert.That(first.Severity, Is.EqualTo(SeverityKind.Warning));

            var second = results.ElementAt(1);

            Assert.That(second.Id, Is.EqualTo("MA-0500"));
            Assert.That(second.Description, Is.EqualTo("The referenced MeasurementScale 1191838a-0f9f-4d2c-8369-cf729d281dee:SCALE of QuantityKind.DefaultScale is deprecated"));
            Assert.That(second.Thing, Is.EqualTo(this.simpleQuantityKind));
            Assert.That(second.Severity, Is.EqualTo(SeverityKind.Warning));
        }
Example #6
0
        public void VerifyThatWhenContainerRdlIsSetAndUnitIsSetPropertiesAreSet()
        {
            var rdlshortnamename = "rdl shortname";

            var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, this.uri)
            {
                ShortName = rdlshortnamename,
            };

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, this.uri)
            {
                Name      = "simple unit name",
                ShortName = "simpleunitshortname"
            };

            rdl.Unit.Add(simpleUnit);

            var ratioscale = new RatioScale(Guid.NewGuid(), null, this.uri)
            {
                Name      = "ratio scale name",
                ShortName = "ratioscaleshortname"
            };

            ratioscale.Unit = simpleUnit;
            rdl.Scale.Add(ratioscale);

            var measurementScaleRowViewModel = new MeasurementScaleRowViewModel(ratioscale, this.session.Object, null);

            Assert.AreEqual(ratioscale.ShortName, measurementScaleRowViewModel.ShortName);
            Assert.AreEqual(ratioscale.Name, measurementScaleRowViewModel.Name);
            Assert.AreEqual(simpleUnit.ShortName, measurementScaleRowViewModel.MeasurementUnit);
            Assert.AreEqual(rdlshortnamename, measurementScaleRowViewModel.ContainerRdl);
        }
Example #7
0
        public void VerifyThatValidatePocoPropertiesAddsScaleValueDefinitionError()
        {
            Assert.DoesNotThrowAsync(async() => await this.session.Object.Open());

            var ratioScale = new RatioScale(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                            this.session.Object.Credentials.Uri);
            var scaleValueDefinition = new ScaleValueDefinition(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                                this.session.Object.Credentials.Uri);

            ratioScale.ValueDefinition.Add(scaleValueDefinition);

            this.siteReferenceDataLibrary.Scale.Add(ratioScale);

            scaleValueDefinition.ValidatePoco();

            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(scaleValueDefinition.Iid, null),
                                                       new Lazy <Thing>(() => scaleValueDefinition));

            this.viewModel.BindPocoErrors();

            Assert.That(this.viewModel.Errors.Any(e => e.Error.Contains("The property Name is null or empty")));
            Assert.That(this.viewModel.Errors.Any(e => e.Error.Contains("The property ShortName is null or empty")));

            Assert.DoesNotThrow(() => this.viewModel.FixCommand.Execute(null));

            Assert.AreEqual(0, this.viewModel.Errors.Count(e => e.Error.Contains("The property Name is null or empty")));
            Assert.AreEqual(0, this.viewModel.Errors.Count(e => e.Error.Contains("The property ShortName is null or empty")));

            Assert.DoesNotThrowAsync(async() => await this.session.Object.Close());
        }
Example #8
0
        public async Task VerifyThatParameterGetsCreatedWhenParameterTypeIsDropped()
        {
            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.Owner = domainOfExpertise;
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            elementDefinition.ParameterGroup.Add(parameterGroup);

            var row = new ParameterGroupRowViewModel(parameterGroup, domainOfExpertise, this.session.Object, null);

            row.ThingCreator = this.thingCreator.Object;

            var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ratioScale         = new RatioScale(Guid.NewGuid(), null, null);

            simpleQuantityKind.DefaultScale = ratioScale;

            var payload  = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale);
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(payload);
            dropInfo.SetupProperty(x => x.Effects);

            await row.Drop(dropInfo.Object);

            this.thingCreator.Verify(x => x.CreateParameter(elementDefinition, parameterGroup, simpleQuantityKind, ratioScale, domainOfExpertise, this.session.Object));
        }
        public void VerifyThatExistingParameterTypeDragOverSetsNoneEffectNoPermission()
        {
            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), null, null);

            elementDefinition.Owner = domainOfExpertise;
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup);

            var row = new ElementDefinitionRowViewModel(this.elementDefinition, this.activeDomain, this.session.Object, null, this.obfuscationService.Object);

            var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null);
            var ratioScale         = new RatioScale(Guid.NewGuid(), null, null);

            simpleQuantityKind.DefaultScale = ratioScale;

            this.srdl.ParameterType.Add(simpleQuantityKind);

            var payload  = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale);
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(payload);
            dropInfo.SetupProperty(x => x.Effects);

            row.DragOver(dropInfo.Object);

            Assert.AreEqual(DragDropEffects.None, dropInfo.Object.Effects);
        }
Example #10
0
        public void Verify_that_when_referenced_DeprecatableThing_Is_Deprecated_result_is_returned()
        {
            var scale = new RatioScale()
            {
                Iid          = Guid.Parse("7f1bacf8-9517-44d1-aead-6cf9c3027db7"),
                ShortName    = "RATIO",
                IsDeprecated = true
            };

            var parameterType = new TextParameterType()
            {
                Iid          = Guid.Parse("7f1bacf8-9517-44d1-aead-6cf9c3027db7"),
                ShortName    = "TEXT",
                IsDeprecated = true
            };

            this.parameter.Scale         = scale;
            this.parameter.ParameterType = parameterType;

            var results = this.parameterBaseRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.parameter);

            var first = results.First();

            Assert.That(first.Id, Is.EqualTo("MA-0500"));
            Assert.That(first.Description, Is.EqualTo("The referenced MeasurementScale 7f1bacf8-9517-44d1-aead-6cf9c3027db7:RATIO of ParameterBase.Scale is deprecated"));
            Assert.That(first.Thing, Is.EqualTo(this.parameter));
            Assert.That(first.Severity, Is.EqualTo(SeverityKind.Warning));

            var second = results.ElementAt(1);

            Assert.That(second.Id, Is.EqualTo("MA-0500"));
            Assert.That(second.Description, Is.EqualTo("The referenced ParameterType 7f1bacf8-9517-44d1-aead-6cf9c3027db7:TEXT of ParameterBase.ParameterType is deprecated"));
            Assert.That(second.Thing, Is.EqualTo(this.parameter));
            Assert.That(second.Severity, Is.EqualTo(SeverityKind.Warning));
        }
        public void VerifyThatParameterTypeNotInChainRdlCannotBeDrop()
        {
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);

            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), null, null);

            elementDefinition.Owner = domainOfExpertise;
            var parameterGroup = new ParameterGroup(Guid.NewGuid(), null, null);

            elementDefinition.ParameterGroup.Add(parameterGroup);

            var row = new ElementDefinitionRowViewModel(this.elementDefinition, this.activeDomain, this.session.Object, null, this.obfuscationService.Object);

            var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null);
            var ratioScale         = new RatioScale(Guid.NewGuid(), null, null);

            simpleQuantityKind.DefaultScale = ratioScale;

            var payload  = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale);
            var dropInfo = new Mock <IDropInfo>();

            dropInfo.Setup(x => x.Payload).Returns(payload);
            dropInfo.SetupProperty(x => x.Effects);

            row.DragOver(dropInfo.Object);

            Assert.AreEqual(DragDropEffects.None, dropInfo.Object.Effects);
        }
        public void VerifyThatScalesFromExistingRdlsAreLoaded()
        {
            var siterefenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null);
            var ratioscale1            = new RatioScale(Guid.NewGuid(), null, null);
            var ratioscale2            = new RatioScale(Guid.NewGuid(), null, null);

            siterefenceDataLibrary.Scale.Add(ratioscale1);
            siterefenceDataLibrary.Scale.Add(ratioscale2);
            this.siteDirectory.SiteReferenceDataLibrary.Add(siterefenceDataLibrary);

            var engineeringModelSetup     = new EngineeringModelSetup(Guid.NewGuid(), null, null);
            var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null);
            var ratioscale3 = new RatioScale(Guid.NewGuid(), null, null);
            var ratioscale4 = new RatioScale(Guid.NewGuid(), null, null);

            modelReferenceDataLibrary.Scale.Add(ratioscale3);
            modelReferenceDataLibrary.Scale.Add(ratioscale4);
            engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary);
            this.siteDirectory.Model.Add(engineeringModelSetup);
            this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDirectory.SiteReferenceDataLibrary)
            {
                modelReferenceDataLibrary
            });

            var browser = new MeasurementScalesBrowserViewModel(this.session.Object, this.siteDirectory, null, null, null, null);

            Assert.AreEqual(4, browser.MeasurementScales.Count);

            browser.Dispose();
            Assert.IsNull(browser.MeasurementScales.First().Thing);
        }
Example #13
0
        public void VerifyThatPopulatePossibleScalesWorks()
        {
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.ActivePerson).Returns(new Person(Guid.NewGuid(), null, this.uri));

            var pt = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri)
            {
                ShortName = "test"
            };

            this.mrdl.ParameterType.Add(pt);

            var scale = new RatioScale(Guid.NewGuid(), null, this.uri)
            {
                ShortName = "testms"
            };

            this.mrdl.Scale.Add(scale);
            pt.PossibleScale.Add(scale);

            var vm = new SimpleParameterValueDialogViewModel(this.parameterValue.Clone(false), this.thingTransaction,
                                                             this.session.Object, true, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.requirementClone);

            vm.SelectedParameterType = pt;

            Assert.AreEqual(0, vm.PossibleScale.Count);
        }
Example #14
0
        public void Verify_that_The_ParameterTypeComponent_has_a_valid_scale()
        {
            var scale              = new RatioScale();
            var textParameterType  = new TextParameterType();
            var simpleQuantityKind = new SimpleQuantityKind();

            this.parameterTypeComponent.Scale         = scale;
            this.parameterTypeComponent.ParameterType = textParameterType;

            var result = this.parameterTypeComponentRuleChecker.ChecksWhetherTheParameterTypeComponentHasAValidScale(this.parameterTypeComponent).Single();

            Assert.That(result.Id, Is.EqualTo("MA-0740"));
            Assert.That(result.Description, Is.EqualTo("When the referenced ParameterType is a not QuantityKind, the ParameterTypeComponent.Scale must be null"));
            Assert.That(result.Thing, Is.EqualTo(this.parameterTypeComponent));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));

            this.parameterTypeComponent.Scale         = null;
            this.parameterTypeComponent.ParameterType = simpleQuantityKind;

            result = this.parameterTypeComponentRuleChecker.ChecksWhetherTheParameterTypeComponentHasAValidScale(this.parameterTypeComponent).Single();

            Assert.That(result.Id, Is.EqualTo("MA-0740"));
            Assert.That(result.Description, Is.EqualTo("When the referenced ParameterType is a QuantityKind, the ParameterTypeComponent.Scale may not be null"));
            Assert.That(result.Thing, Is.EqualTo(this.parameterTypeComponent));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));
        }
        public void VerifyThatTheConstructorSetsTheProperties()
        {
            var shortname = "constantshortname";
            var name      = "constant name";

            var ratioScale = new RatioScale(Guid.NewGuid(), null, this.uri)
            {
                Name      = "ratio scale",
                ShortName = "ratioscaleshortname",
            };

            var qk = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri);

            qk.DefaultScale = ratioScale;

            var constant = new Constant(Guid.NewGuid(), null, this.uri)
            {
                Name          = name,
                ShortName     = shortname,
                ParameterType = qk,
                Scale         = ratioScale
            };

            var constantRowViewModel = new ConstantRowViewModel(constant, this.session.Object, null);

            Assert.AreEqual(shortname, constantRowViewModel.ShortName);
            Assert.AreEqual(name, constantRowViewModel.Name);
            Assert.AreEqual(string.Empty, constantRowViewModel.ContainerRdl);
            Assert.AreEqual(ratioScale, constantRowViewModel.SelectedScale);
        }
Example #16
0
        public void SetUp()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            this.uri   = new Uri("http://www.rheagroup.com");
            this.cache = new ConcurrentDictionary <CDP4Common.Types.CacheKey, Lazy <Thing> >();

            this.ratioScale = new RatioScale(Guid.NewGuid(), this.cache, this.uri);

            var valuedefLow = new EnumerationValueDefinition(Guid.NewGuid(), this.cache, this.uri);

            valuedefLow.ShortName = "low";
            var valuedefMedium = new EnumerationValueDefinition(Guid.NewGuid(), this.cache, this.uri);

            valuedefMedium.ShortName = "medium";

            this.booleanParameterType  = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri);
            this.dateParameterType     = new DateParameterType(Guid.NewGuid(), this.cache, this.uri);
            this.dateTimeParameterType = new DateTimeParameterType(Guid.NewGuid(), this.cache, this.uri);

            this.enumerationParameterType      = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri);
            this.enumerationParameterType.Name = "test";
            this.enumerationParameterType.ValueDefinition.Add(valuedefLow);
            this.enumerationParameterType.ValueDefinition.Add(valuedefMedium);

            this.simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri);
            this.simpleQuantityKind.PossibleScale.Add(this.ratioScale);
            this.simpleQuantityKind.DefaultScale = this.ratioScale;

            this.textParameterType      = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);
            this.timeOfDayParameterType = new TimeOfDayParameterType(Guid.NewGuid(), this.cache, this.uri);
        }
Example #17
0
        public void Verify_that_when_referenced_DeprecatableThing_Is_Deprecated_result_is_returned()
        {
            var scale = new RatioScale
            {
                Iid          = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"),
                ShortName    = "SCALE",
                IsDeprecated = true
            };

            var parameterType = new TextParameterType()
            {
                Iid          = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"),
                ShortName    = "TEXT",
                IsDeprecated = true
            };

            this.simpleParameterValue.Scale         = scale;
            this.simpleParameterValue.ParameterType = parameterType;

            var results = this.simpleParameterValueRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.simpleParameterValue);

            var first = results.First();

            Assert.That(first.Id, Is.EqualTo("MA-0500"));
            Assert.That(first.Description, Is.EqualTo("The referenced MeasurementScale 1191838a-0f9f-4d2c-8369-cf729d281dee:SCALE of SimpleParameterValue.Scale is deprecated"));
            Assert.That(first.Thing, Is.EqualTo(this.simpleParameterValue));
            Assert.That(first.Severity, Is.EqualTo(SeverityKind.Warning));

            var second = results.ElementAt(1);

            Assert.That(second.Id, Is.EqualTo("MA-0500"));
            Assert.That(second.Description, Is.EqualTo("The referenced ParameterType 1191838a-0f9f-4d2c-8369-cf729d281dee:TEXT of SimpleParameterValue.ParameterType is deprecated"));
            Assert.That(second.Thing, Is.EqualTo(this.simpleParameterValue));
            Assert.That(second.Severity, Is.EqualTo(SeverityKind.Warning));
        }
Example #18
0
        public void Verify_that_when_the_DefaultScale_is_not_in_the_PossibleScales_a_result_is_returned()
        {
            var ratioScale_1 = new RatioScale {
                Iid = Guid.Parse("9fd6eb4f-5fb8-469f-8798-20bf4dd84e95"), ShortName = "scale_1"
            };
            var ratioScale_2 = new RatioScale {
                Iid = Guid.Parse("eed266d7-3ce5-4117-8ca4-2db316ec9cc6"), ShortName = "scale_2"
            };
            var ratioScale_3 = new RatioScale {
                Iid = Guid.Parse("918abf39-87af-4305-91e8-28c17ab274b2"), ShortName = "scale_3"
            };

            var sqk = new SimpleQuantityKind();

            sqk.PossibleScale.Add(ratioScale_1);
            sqk.PossibleScale.Add(ratioScale_2);

            sqk.DefaultScale = ratioScale_3;

            var result = this.quantityKindRuleChecker.ChecksWhetherReferencedDefaultScaleIsInTheCollectionOfPossibleScales(sqk).Single();

            Assert.That(result.Id, Is.EqualTo("MA-0750"));
            Assert.That(result.Description, Is.EqualTo("The QuantityKind.DefaultScale 918abf39-87af-4305-91e8-28c17ab274b2:scale_3 is not in the list of QuantityKind.PossibleScale"));
            Assert.That(result.Thing, Is.EqualTo(sqk));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));
        }
Example #19
0
        /// <summary>
        /// Serialize the <see cref="RatioScale"/>
        /// </summary>
        /// <param name="ratioScale">The <see cref="RatioScale"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(RatioScale ratioScale)
        {
            var jsonObject = new JObject();

            jsonObject.Add("alias", this.PropertySerializerMap["alias"](ratioScale.Alias.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), ratioScale.ClassKind)));
            jsonObject.Add("definition", this.PropertySerializerMap["definition"](ratioScale.Definition.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](ratioScale.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](ratioScale.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](ratioScale.HyperLink.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](ratioScale.Iid));
            jsonObject.Add("isDeprecated", this.PropertySerializerMap["isDeprecated"](ratioScale.IsDeprecated));
            jsonObject.Add("isMaximumInclusive", this.PropertySerializerMap["isMaximumInclusive"](ratioScale.IsMaximumInclusive));
            jsonObject.Add("isMinimumInclusive", this.PropertySerializerMap["isMinimumInclusive"](ratioScale.IsMinimumInclusive));
            jsonObject.Add("mappingToReferenceScale", this.PropertySerializerMap["mappingToReferenceScale"](ratioScale.MappingToReferenceScale.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("maximumPermissibleValue", this.PropertySerializerMap["maximumPermissibleValue"](ratioScale.MaximumPermissibleValue));
            jsonObject.Add("minimumPermissibleValue", this.PropertySerializerMap["minimumPermissibleValue"](ratioScale.MinimumPermissibleValue));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](ratioScale.ModifiedOn));
            jsonObject.Add("name", this.PropertySerializerMap["name"](ratioScale.Name));
            jsonObject.Add("negativeValueConnotation", this.PropertySerializerMap["negativeValueConnotation"](ratioScale.NegativeValueConnotation));
            jsonObject.Add("numberSet", this.PropertySerializerMap["numberSet"](Enum.GetName(typeof(CDP4Common.SiteDirectoryData.NumberSetKind), ratioScale.NumberSet)));
            jsonObject.Add("positiveValueConnotation", this.PropertySerializerMap["positiveValueConnotation"](ratioScale.PositiveValueConnotation));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](ratioScale.RevisionNumber));
            jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](ratioScale.ShortName));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](ratioScale.ThingPreference));
            jsonObject.Add("unit", this.PropertySerializerMap["unit"](ratioScale.Unit));
            jsonObject.Add("valueDefinition", this.PropertySerializerMap["valueDefinition"](ratioScale.ValueDefinition.OrderBy(x => x, this.guidComparer)));
            return(jsonObject);
        }
        public void Verify_that_IsMeasurementScaleInChainOfRdls_returns_expected_result()
        {
            var ratioScale = new RatioScale();

            Assert.That(this.mRdl.IsMeasurementScaleInChainOfRdls(ratioScale), Is.False);

            this.sRdl1.Scale.Add(ratioScale);
            Assert.That(this.mRdl.IsMeasurementScaleInChainOfRdls(ratioScale), Is.True);
        }
Example #21
0
        public void Verify_that_when_referenced_MeasurementScale_is_in_chain_of_rdls_no_result_is_returned()
        {
            var scale = new RatioScale();

            this.modelReferenceDataLibrary.Scale.Add(scale);
            this.parameter.Scale = scale;

            var results = this.parameterBaseRuleChecker.CheckWhetherReferencedMeasurementScaleInChainOfRdls(this.parameter);

            Assert.That(results, Is.Empty);
        }
 public void VerifyUpdateOkCanExecute()
 {
     Assert.IsFalse(this.viewmodel.OkCommand.CanExecute(null));
     Assert.IsEmpty(this.viewmodel.PossibleScale);
     var testScale = new RatioScale();
     this.viewmodel.PossibleScale.Add(testScale);
     Assert.IsFalse(this.viewmodel.OkCommand.CanExecute(null));
     Assert.IsNull(this.viewmodel.SelectedDefaultScale);
     this.viewmodel.SelectedDefaultScale = testScale;
     Assert.IsTrue(this.viewmodel.OkCommand.CanExecute(null));
 }
        public void SetUp()
        {
            this.measurementScaleRuleChecker = new MeasurementScaleRuleChecker();

            this.siteReferenceDataLibrary = new SiteReferenceDataLibrary();
            this.ratioScale = new RatioScale()
            {
                Iid = Guid.NewGuid()
            };

            this.siteReferenceDataLibrary.Scale.Add(this.ratioScale);
        }
Example #24
0
        public void Verify_that_when_referenced_MeasurementScale_is_in_chain_of_rdls_no_result_is_returned()
        {
            var scale = new RatioScale {
                Iid = Guid.Parse("833f1e3e-0b2e-49ca-b1b0-ef6d627210d0"), ShortName = "SCALE"
            };

            this.siteReferenceDataLibrary.Scale.Add(scale);
            this.parameterTypeComponent.Scale = scale;

            var results = this.parameterTypeComponentRuleChecker.CheckWhetherReferencedMeasurementScaleInChainOfRdls(this.parameterTypeComponent);

            Assert.That(results, Is.Empty);
        }
Example #25
0
        public void VerifyThatCreateParameterThrowsExceptionWhenElementDefinitionIsNull()
        {
            var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, null);
            var group             = new ParameterGroup(Guid.NewGuid(), this.cache, null);
            var parameterType     = new BooleanParameterType(Guid.NewGuid(), this.cache, null);
            var scale             = new RatioScale(Guid.NewGuid(), this.cache, null);
            var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, null);

            Assert.ThrowsAsync <ArgumentNullException>(async() => await this.thingCreator.CreateParameter(null, group, parameterType, scale, domainOfExpertise, this.session.Object));
            Assert.ThrowsAsync <ArgumentNullException>(async() => await this.thingCreator.CreateParameter(elementDefinition, group, null, scale, domainOfExpertise, this.session.Object));
            Assert.ThrowsAsync <ArgumentNullException>(async() => await this.thingCreator.CreateParameter(elementDefinition, group, parameterType, scale, null, this.session.Object));
            Assert.ThrowsAsync <ArgumentNullException>(async() => await this.thingCreator.CreateParameter(elementDefinition, group, parameterType, scale, domainOfExpertise, null));
        }
Example #26
0
        public void Verify_that_when_referenced_MeasurementScale_is_in_chain_of_rdls_no_result_is_returned()
        {
            var scale = new RatioScale {
                Iid = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"), ShortName = "SCALE"
            };

            this.modelReferenceDataLibrary.Scale.Add(scale);

            this.simpleParameterValue.Scale = scale;

            var results = this.simpleParameterValueRuleChecker.CheckWhetherReferencedMeasurementScaleInChainOfRdls(this.simpleParameterValue);

            Assert.That(results, Is.Empty);
        }
        public void Verify_that_QueryMeasurementScalesFromChainOfRdls_returns_expected_result()
        {
            var mRdl_RatioScale   = new RatioScale(Guid.NewGuid(), null, null);
            var sRdl1_RatioScale  = new RatioScale(Guid.NewGuid(), null, null);
            var sRdl11_RatioScale = new RatioScale(Guid.NewGuid(), null, null);

            this.mRdl.Scale.Add(mRdl_RatioScale);
            this.sRdl1.Scale.Add(sRdl1_RatioScale);
            this.sRdl11.Scale.Add(sRdl11_RatioScale);

            Assert.That(new List <MeasurementScale> {
                mRdl_RatioScale, sRdl1_RatioScale, sRdl11_RatioScale
            }, Is.EquivalentTo(this.mRdl.QueryMeasurementScalesFromChainOfRdls()));
        }
Example #28
0
        public void Verify_that_when_referenced_DeprecatableThing_Is_not_Deprecated_no_result_is_returned()
        {
            var scale = new RatioScale
            {
                Iid          = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"),
                ShortName    = "SCALE",
                IsDeprecated = false
            };

            this.scaleReferenceQuantityValue.Scale = scale;

            var results = this.scaleReferenceQuantityValueRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.scaleReferenceQuantityValue);

            Assert.That(results, Is.Empty);
        }
Example #29
0
        public void VerifyThatThePropertiesAreUpdateWhenParameterTypeIsUpdated()
        {
            var rev = typeof(Thing).GetProperty("RevisionNumber");

            var rdlshortnamename = "rdl shortname";
            var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ShortName = rdlshortnamename,
            };

            var ratioScale = new RatioScale(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ShortName = "RatioScale"
            };
            var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name         = "simple quantity kind",
                ShortName    = "sqk",
                DefaultScale = ratioScale,
            };

            rdl.ParameterType.Add(simpleQuantityKind);
            rdl.BaseQuantityKind.Add(simpleQuantityKind);
            var parameterTypeRowViewModel = new ParameterTypeRowViewModel(simpleQuantityKind, this.session.Object, null);

            var updatedName      = "updated quantity kind Shortname";
            var updatedShortName = "updatedQKShortName";
            var updatedScale     = "updatedScale";

            simpleQuantityKind.ShortName = updatedShortName;
            simpleQuantityKind.Name      = updatedName;

            rev.SetValue(simpleQuantityKind, 10);
            CDPMessageBus.Current.SendObjectChangeEvent(simpleQuantityKind, EventKind.Updated);

            Assert.AreEqual(simpleQuantityKind.ShortName, parameterTypeRowViewModel.ShortName);
            Assert.AreEqual(simpleQuantityKind.Name, parameterTypeRowViewModel.Name);
            Assert.IsTrue(parameterTypeRowViewModel.IsBaseQuantityKind);
            Assert.AreEqual(simpleQuantityKind.DefaultScale.ShortName, parameterTypeRowViewModel.DefaultScale);
            Assert.AreEqual(simpleQuantityKind.ClassKind.ToString(), parameterTypeRowViewModel.Type);
            Assert.AreEqual(rdlshortnamename, parameterTypeRowViewModel.ContainerRdl);

            ratioScale.ShortName = updatedScale;
            rev.SetValue(ratioScale, 10);
            CDPMessageBus.Current.SendObjectChangeEvent(ratioScale, EventKind.Updated);
            Assert.AreEqual(updatedScale, parameterTypeRowViewModel.DefaultScale);
        }
Example #30
0
        public void Verify_that_when_DeprecatableThing_Is_Deprecated_no_result_is_returned()
        {
            var scale = new RatioScale
            {
                Iid          = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"),
                ShortName    = "SCALE",
                IsDeprecated = true
            };

            this.simpleQuantityKind.PossibleScale.Add(scale);
            this.simpleQuantityKind.DefaultScale = scale;
            this.simpleQuantityKind.IsDeprecated = true;

            var results = this.quantityKindRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.simpleQuantityKind);

            Assert.That(results, Is.Empty);
        }