Exemplo n.º 1
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);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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 VerifyThatAllPropertiesArePopulated()
        {
            var shortname = "shortname";
            var name      = "name";

            var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri);

            rule.ShortName = shortname;
            rule.Name      = name;
            rule.Category  = this.cat;
            var pt = new TextParameterType(Guid.NewGuid(), null, this.uri);

            this.siteRdl.ParameterType.Add(pt);
            this.siteRdl.Rule.Add(rule);
            rule.ParameterType.Add(this.siteRdl.ParameterType.First());

            var vm = new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.dialogService.Object);

            Assert.AreEqual(shortname, vm.ShortName);
            Assert.AreEqual(name, vm.Name);
            Assert.AreEqual(1, vm.PossibleCategory.Count);
            Assert.AreEqual(this.cat, vm.PossibleCategory.First());
            Assert.AreEqual(this.cat, vm.SelectedCategory);
            Assert.AreEqual(1, vm.PossibleParameterType.Count);
            Assert.AreEqual(pt, vm.PossibleParameterType.First());
            Assert.AreEqual(1, vm.ParameterType.Count);
            Assert.AreEqual(pt, vm.ParameterType.First());

            Assert.IsTrue(vm.OkCanExecute);
        }
Exemplo n.º 6
0
        public void VerifyThatParametertypesFromExistingRdlsAreLoaded()
        {
            var siterefenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null);
            var pt1 = new TextParameterType(Guid.NewGuid(), null, null);
            var pt2 = new TextParameterType(Guid.NewGuid(), null, null);

            siterefenceDataLibrary.ParameterType.Add(pt1);
            siterefenceDataLibrary.ParameterType.Add(pt2);
            this.siteDirectory.SiteReferenceDataLibrary.Add(siterefenceDataLibrary);

            var engineeringModelSetup     = new EngineeringModelSetup(Guid.NewGuid(), null, null);
            var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null);
            var pt3 = new BooleanParameterType(Guid.NewGuid(), null, null);
            var pt4 = new BooleanParameterType(Guid.NewGuid(), null, null);

            modelReferenceDataLibrary.ParameterType.Add(pt3);
            modelReferenceDataLibrary.ParameterType.Add(pt4);
            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 ParameterTypesBrowserViewModel(this.session.Object, this.siteDirectory, null, null, null,
                                                             null, this.favoritesService.Object);

            Assert.AreEqual(4, browser.ParameterTypes.Count);
            Assert.IsNotNull(browser.ParameterTypes.First().Thing);

            browser.Dispose();
            Assert.IsNull(browser.ParameterTypes.First().Thing);
        }
        public void VerifyFormatOfTextParameterType()
        {
            var textParameterType = new TextParameterType();
            var format            = NumberFormat.Format(textParameterType);

            Assert.AreEqual("@", format);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Validates the <param name="value"></param> to check whether it is Text.
        /// </summary>
        /// <param name="parameterType">
        /// A <see cref="TextParameterType"/>
        /// </param>
        /// <param name="value">
        /// the text value
        /// </param>
        /// <returns>
        /// a <see cref="ValidationResult"/> that carries the <see cref="ValidationResultKind"/> and an optional message.
        /// </returns>
        public static ValidationResult Validate(this TextParameterType parameterType, string value)
        {
            ValidationResult result;

            result.ResultKind = ValidationResultKind.Valid;
            result.Message    = string.Empty;
            return(result);
        }
        public void Verify_that_IsParameterTypeInChainOfRdls_returns_expected_result()
        {
            var parameterType = new TextParameterType();

            Assert.That(this.mRdl.IsParameterTypeInChainOfRdls(parameterType), Is.False);

            this.sRdl1.ParameterType.Add(parameterType);
            Assert.That(this.mRdl.IsParameterTypeInChainOfRdls(parameterType), Is.True);
        }
Exemplo n.º 10
0
        public void VerifyThatIfParameterTypeOfParameterBaseIsNotCompoundArgumentExecptionIsThrown()
        {
            var parameter         = new Parameter(Guid.NewGuid(), this.cache, this.uri);
            var textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);

            parameter.ParameterType = textParameterType;

            Assert.Throws <InvalidOperationException>(() => new ParameterComponentValueRowViewModel(parameter, 0, this.session.Object, null, null, null));
        }
Exemplo n.º 11
0
        public void Verify_that_when_referenced_ParameterType_is_in_chain_of_rdls_no_result_is_returned()
        {
            var parameterType = new TextParameterType();

            this.siteReferenceDataLibrary.ParameterType.Add(parameterType);
            this.parameterTypeComponent.ParameterType = parameterType;

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

            Assert.That(results, Is.Empty);
        }
        public void VerifyThatThingStatusIsNotNull()
        {
            var parameter         = new Parameter(Guid.NewGuid(), this.cache, this.uri);
            var textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);

            parameter.ParameterType     = textParameterType;
            parameter.IsOptionDependent = true;

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

            Assert.IsNotNull(row.ThingStatus);
        }
Exemplo n.º 13
0
        public void SetUp()
        {
            this.uri = new Uri("http://www.rheagroup.com");
            this.cache = new ConcurrentDictionary<CDP4Common.Types.CacheKey, Lazy<Thing>>();

            this.CreateCategories();

            this.textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri) { ShortName = "TXT" };
            this.simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) {ShortName = "SIMPLE" };

            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);
        }
Exemplo n.º 14
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.serviceLocator       = new Mock <IServiceLocator>();
            this.navigation           = new Mock <IThingDialogNavigationService>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IThingDialogNavigationService>()).Returns(this.navigation.Object);
            this.permissionService = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.session = new Mock <ISession>();
            var person = new Person(Guid.NewGuid(), null, null)
            {
                Container = this.siteDir
            };

            this.session.Setup(x => x.ActivePerson).Returns(person);

            this.siteDir = new SiteDirectory(Guid.NewGuid(), null, null);
            this.siteDir.Person.Add(person);
            var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null)
            {
                Name = "testRDL", ShortName = "test"
            };

            this.textParameterType = new TextParameterType(Guid.NewGuid(), null, null)
            {
                Name = "textParameterType", ShortName = "cat"
            };
            var cat = new Category(Guid.NewGuid(), null, null)
            {
                Name = "category1", ShortName = "cat1"
            };

            cat.PermissibleClass.Add(ClassKind.TextParameterType);
            rdl.DefinedCategory.Add(cat);
            this.siteDir.SiteReferenceDataLibrary.Add(rdl);

            var transactionContext = TransactionContextResolver.ResolveContext(this.siteDir);

            this.transaction = new ThingTransaction(transactionContext, null);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary));

            var dal = new Mock <IDal>();

            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);
            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());

            this.viewmodel = new TextParameterTypeDialogViewModel(this.textParameterType, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, null, null);
        }
Exemplo n.º 15
0
        public async Task Verify_that_Update_dos_not_Executes_when_there_are_no_IOwnedThings()
        {
            var classKinds = new List <ClassKind> {
                ClassKind.ElementUsage, ClassKind.Parameter
            };

            var parameterType = new TextParameterType();

            await this.changeOwnershipBatchService.Update(this.session.Object, parameterType, this.systemEngineering, true, classKinds);

            this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Never);
        }
        public void VerifyThatParameterTypeEventsAreCaught()
        {
            var textParamType = new TextParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);

            CDPMessageBus.Current.SendObjectChangeEvent(textParamType, EventKind.Added);
            Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count);
            CDPMessageBus.Current.SendObjectChangeEvent(textParamType, EventKind.Removed);
            Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any());

            var booleanParamType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);

            CDPMessageBus.Current.SendObjectChangeEvent(booleanParamType, EventKind.Added);
            Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count);
            CDPMessageBus.Current.SendObjectChangeEvent(booleanParamType, EventKind.Removed);
            Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any());

            var defaultScale = new CyclicRatioScale(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var simpleQuantityKind =
                new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                DefaultScale = defaultScale
            };

            CDPMessageBus.Current.SendObjectChangeEvent(simpleQuantityKind, EventKind.Added);
            Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count);
            CDPMessageBus.Current.SendObjectChangeEvent(simpleQuantityKind, EventKind.Removed);
            Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any());

            var specializedQuantityKind =
                new SpecializedQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                DefaultScale = defaultScale
            };

            CDPMessageBus.Current.SendObjectChangeEvent(specializedQuantityKind, EventKind.Added);
            Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count);
            CDPMessageBus.Current.SendObjectChangeEvent(specializedQuantityKind, EventKind.Removed);
            Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any());

            var derivedQuantityKind =
                new DerivedQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                DefaultScale = defaultScale
            };

            CDPMessageBus.Current.SendObjectChangeEvent(derivedQuantityKind, EventKind.Added);
            Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count);
            CDPMessageBus.Current.SendObjectChangeEvent(derivedQuantityKind, EventKind.Removed);
            Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any());
        }
Exemplo n.º 17
0
        public void Verify_that_when_referenced_ParameterType_is_in_chain_of_rdl_no_result_is_returned()
        {
            var parameterType = new TextParameterType {
                Iid = Guid.Parse("df9031c7-85f2-4728-b303-146835e97fc3"), ShortName = "TEXT"
            };

            this.siteReferenceDataLibrary.ParameterType.Add(parameterType);

            this.parameterizedCategoryRule.ParameterType.Add(parameterType);

            var results = this.parameterizedCategoryRuleRuleChecker.CheckWhetherReferencedParameterTypeIsInChainOfRdls(this.parameterizedCategoryRule);

            Assert.That(results, Is.Empty);
        }
Exemplo n.º 18
0
        public void Verify_that_when_ParameterType_is_in_chain_of_Rdls_no_result_is_returned()
        {
            var parameterType = new TextParameterType {
                Iid = Guid.Parse("3c44c0e3-d2de-43f9-9636-8235984dc4bf"), ShortName = "TEXT"
            };

            this.modelReferenceDataLibrary.ParameterType.Add(parameterType);

            this.parameter.ParameterType = parameterType;

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

            Assert.That(results, Is.Empty);
        }
Exemplo n.º 19
0
        public void Verify_that_when_ParameterType_is_in_chain_of_Rdls_no_result_is_returned()
        {
            var parameterType = new TextParameterType {
                Iid = Guid.Parse("aaaafb1c-7b33-4602-89c9-85626c28b904")
            };

            this.modelReferenceDataLibrary.ParameterType.Add(parameterType);

            this.simpleParameterValue.ParameterType = parameterType;

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

            Assert.That(results, Is.Empty);
        }
Exemplo n.º 20
0
        public void Verify_that_IsCategoryInChainOfRdls_returns_true_when_category_is_in_same_chain_of_rdls_as_ParameterType_and_false_otherwise()
        {
            var parameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);

            this.siteRdl_A_A.ParameterType.Add(parameterType);

            Assert.That(parameterType.IsCategoryInChainOfRdls(this.productCategory), Is.True);
            Assert.That(parameterType.IsCategoryInChainOfRdls(this.equipmentCategory), Is.True);
            Assert.That(parameterType.IsCategoryInChainOfRdls(this.lithiumBatteryCategory), Is.True);

            Assert.That(parameterType.IsCategoryInChainOfRdls(this.transmitterCategory), Is.False);

            Assert.That(this.elementDefinition.IsCategoryInChainOfRdls(this.functionCategory), Is.False);
        }
        public void Verify_that_QueryParameterTypesFromChainOfRdls_returns_expected_result()
        {
            var mRdl_TextParameterType   = new TextParameterType(Guid.NewGuid(), null, null);
            var sRdl1_TextParameterType  = new TextParameterType(Guid.NewGuid(), null, null);
            var sRdl11_TextParameterType = new TextParameterType(Guid.NewGuid(), null, null);

            this.mRdl.ParameterType.Add(mRdl_TextParameterType);
            this.sRdl1.ParameterType.Add(sRdl1_TextParameterType);
            this.sRdl11.ParameterType.Add(sRdl11_TextParameterType);

            Assert.That(new List <ParameterType> {
                mRdl_TextParameterType, sRdl1_TextParameterType, sRdl11_TextParameterType
            }, Is.EquivalentTo(this.mRdl.QueryParameterTypesFromChainOfRdls()));
        }
        public void VerifyUpdateOkCanExecute()
        {
            var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri);
            var vm   = new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object);

            Assert.IsFalse(vm.OkCanExecute);

            vm.Container = this.siteRdl;
            Assert.IsFalse(vm.OkCanExecute);
            vm.SelectedCategory = this.cat;
            Assert.IsFalse(vm.OkCanExecute);
            var pt = new TextParameterType(Guid.NewGuid(), null, this.uri);

            vm.ParameterType.Add(pt);
            Assert.IsTrue(vm.OkCanExecute);
        }
        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));
        }
Exemplo n.º 24
0
        public void SetUp()
        {
            this.uri   = new Uri("http://www.rheagroup.com");
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <CDP4Common.CommonData.Thing> >();

            this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            var siteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);

            this.siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary);
            this.textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);
            siteReferenceDataLibrary.ParameterType.Add(this.textParameterType);

            this.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.engineeringModel.RevisionNumber = 2;

            var frozenIterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);

            frozenIterationSetup.FrozenOn = DateTime.Parse("2012-12-12");

            this.frozenIteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.frozenIteration.RevisionNumber = 1;
            this.frozenIteration.IterationSetup = frozenIterationSetup;

            var activeIterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);

            this.activeIteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.activeIteration.RevisionNumber = 2;
            this.activeIteration.IterationSetup = activeIterationSetup;

            this.engineeringModel.Iteration.Add(this.frozenIteration);
            this.engineeringModel.Iteration.Add(this.activeIteration);

            var frozenElementDefinitionIid = Guid.NewGuid();

            this.frozenElementDefinition = new ElementDefinition(frozenElementDefinitionIid, this.cache, this.uri);
            this.frozenElementDefinition.RevisionNumber = 1;
            this.frozenIteration.Element.Add(this.frozenElementDefinition);

            var activeElementDefinitionIid = Guid.NewGuid();

            this.activeElementDefinition = new ElementDefinition(activeElementDefinitionIid, this.cache, this.uri);
            this.activeElementDefinition.RevisionNumber = 2;
            this.activeIteration.Element.Add(this.activeElementDefinition);

            this.book = new Book(Guid.NewGuid(), this.cache, this.uri);
            this.engineeringModel.Book.Add(this.book);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Validates the <param name="value"></param> to check whether it is Text.
        /// </summary>
        /// <param name="parameterType">
        /// A <see cref="TextParameterType"/>
        /// </param>
        /// <param name="value">
        /// The string value that is to be validated.
        /// </param>
        /// <returns>
        /// a <see cref="ValidationResult"/> that carries the <see cref="ValidationResultKind"/> and an optional message.
        /// </returns>
        public static ValidationResult Validate(this TextParameterType parameterType, object value)
        {
            ValidationResult result;

            if (value is string)
            {
                result.ResultKind = ValidationResultKind.Valid;
                result.Message    = string.Empty;
            }
            else
            {
                result.ResultKind = ValidationResultKind.Invalid;
                result.Message    = $"{value} is not a valid value for a Text Parameter Type";
            }

            return(result);
        }
        public void VerifyThatMessageBusMessageWork(IViewModelBase <Thing> container, string scenario)
        {
            var parameter         = new Parameter(Guid.NewGuid(), this.cache, this.uri);
            var textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);

            parameter.ParameterType     = textParameterType;
            parameter.IsOptionDependent = true;

            this.option.Name = "OriginalName";
            var row = new ParameterOptionRowViewModel(parameter, this.option, this.session.Object, container, false);

            Assert.That(row.Name, Is.EqualTo(this.option.Name));

            this.option.Name = "ChangedName";
            CDPMessageBus.Current.SendObjectChangeEvent(this.option, EventKind.Updated);
            Assert.That(row.Name, Is.EqualTo(this.option.Name));
        }
Exemplo n.º 27
0
        public void Verify_that_when_referenced_ParameterType_is_not_in_chain_of_rdls_result_is_returned()
        {
            var parameterType = new TextParameterType {
                Iid = Guid.Parse("55e32513-9e45-4a63-8cd4-e84b2f320a8d")
            };
            var otherSiterReferenceDataLibrary = new SiteReferenceDataLibrary();

            otherSiterReferenceDataLibrary.ParameterType.Add(parameterType);

            this.parameterTypeComponent.ParameterType = parameterType;

            var result = this.parameterTypeComponentRuleChecker.CheckWhetherReferencedParameterTypeIsInChainOfRdls(this.parameterTypeComponent).First();

            Assert.That(result.Id, Is.EqualTo("MA-0220"));
            Assert.That(result.Description, Is.EqualTo("The referenced ParameterType is not in the chain of Reference Data Libraries"));
            Assert.That(result.Thing, Is.EqualTo(this.parameterTypeComponent));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));
        }
Exemplo n.º 28
0
        public void Verify_that_when_ParameterType_is_not_in_chain_of_Rdls_result_is_returned()
        {
            var otherSiteReferenceDataLibrary = new SiteReferenceDataLibrary();
            var parameterType = new TextParameterType {
                Iid = Guid.Parse("aaaafb1c-7b33-4602-89c9-85626c28b904"), ShortName = "TEXT"
            };

            otherSiteReferenceDataLibrary.ParameterType.Add(parameterType);

            this.simpleParameterValue.ParameterType = parameterType;

            var result = this.simpleParameterValueRuleChecker.CheckWhetherReferencedParameterTypeIsInChainOfRdls(this.simpleParameterValue).Single();

            Assert.That(result.Id, Is.EqualTo("MA-0220"));
            Assert.That(result.Description, Is.EqualTo("The referenced ParameterType aaaafb1c-7b33-4602-89c9-85626c28b904:TEXT is not in the chain of Reference Data Libraries"));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));
            Assert.That(result.Thing, Is.EqualTo(this.simpleParameterValue));
        }
Exemplo n.º 29
0
        public void Verify_that_when_ParameterType_is_not_in_chain_of_Rdls_result_is_returned()
        {
            var otherSiteReferenceDataLibrary = new SiteReferenceDataLibrary();
            var parameterType = new TextParameterType {
                Iid = Guid.Parse("3c44c0e3-d2de-43f9-9636-8235984dc4bf"), ShortName = "TEXT"
            };

            otherSiteReferenceDataLibrary.ParameterType.Add(parameterType);

            this.parameter.ParameterType = parameterType;

            var result = this.parameterBaseRuleChecker.CheckWhetherReferencedParameterTypeIsInChainOfRdls(this.parameter).Single();

            Assert.That(result.Id, Is.EqualTo("MA-0220"));
            Assert.That(result.Description, Is.EqualTo("The referenced ParameterType 3c44c0e3-d2de-43f9-9636-8235984dc4bf:TEXT is not in the chain of Reference Data Libraries"));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));
            Assert.That(result.Thing, Is.EqualTo(this.parameter));
        }
Exemplo n.º 30
0
        public void Verify_that_when_referenced_ParameterType_is_not_in_chain_of_rdl_result_is_returned()
        {
            var otherSiteReferenceDataLibrary = new SiteReferenceDataLibrary();
            var parameterType = new TextParameterType {
                Iid = Guid.Parse("df9031c7-85f2-4728-b303-146835e97fc3"), ShortName = "TEXT"
            };

            otherSiteReferenceDataLibrary.ParameterType.Add(parameterType);

            this.parameterizedCategoryRule.ParameterType.Add(parameterType);

            var result = this.parameterizedCategoryRuleRuleChecker.CheckWhetherReferencedParameterTypeIsInChainOfRdls(this.parameterizedCategoryRule).Single();

            Assert.That(result.Id, Is.EqualTo("MA-0220"));
            Assert.That(result.Description, Is.EqualTo("The referenced ParameterType df9031c7-85f2-4728-b303-146835e97fc3:TEXT is not in the chain of Reference Data Libraries"));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));
            Assert.That(result.Thing, Is.EqualTo(this.parameterizedCategoryRule));
        }