Ejemplo n.º 1
0
        /// <summary>
        /// Returns the <see cref="DatatypeDefinitionEnumeration"/> representation of a <see cref="EnumerationParameterType"/>
        /// </summary>
        /// <param name="enumerationParameterType">The <see cref="EnumerationParameterType"/></param>
        /// <returns>the <see cref="DatatypeDefinitionEnumeration"/></returns>
        private DatatypeDefinitionEnumeration ToReqIfDatatypeDefinitionEnumeration(EnumerationParameterType enumerationParameterType)
        {
            var datatype = new DatatypeDefinitionEnumeration();

            this.SetIdentifiableProperties(datatype, enumerationParameterType);

            for (var i = 0; i < enumerationParameterType.ValueDefinition.Count; i++)
            {
                var enumerationValueDefinition = enumerationParameterType.ValueDefinition[i];

                var enumvalue = new EnumValue();
                this.SetIdentifiableProperties(enumvalue, enumerationValueDefinition);
                enumvalue.LongName = enumerationValueDefinition.Name;

                enumvalue.Properties = new EmbeddedValue
                {
                    OtherContent = enumerationValueDefinition.ShortName,
                    Key          = i
                };

                datatype.SpecifiedValues.Add(enumvalue);
            }

            return(datatype);
        }
Ejemplo n.º 2
0
        public void Verify_that_QueryDatatypeName_returns_expected_results()
        {
            var datatypeDefinitionBoolean = new DatatypeDefinitionBoolean();

            Assert.That(datatypeDefinitionBoolean.QueryDatatypeName(), Is.EqualTo("Boolean"));

            var datatypeDefinitionDate = new DatatypeDefinitionDate();

            Assert.That(datatypeDefinitionDate.QueryDatatypeName(), Is.EqualTo("Date"));

            var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration();

            Assert.That(datatypeDefinitionEnumeration.QueryDatatypeName(), Is.EqualTo("Enumeration"));

            var datatypeDefinitionInteger = new DatatypeDefinitionInteger();

            Assert.That(datatypeDefinitionInteger.QueryDatatypeName(), Is.EqualTo("Integer"));

            var datatypeDefinitionReal = new DatatypeDefinitionReal();

            Assert.That(datatypeDefinitionReal.QueryDatatypeName(), Is.EqualTo("Real"));

            var datatypeDefinitionString = new DatatypeDefinitionString();

            Assert.That(datatypeDefinitionString.QueryDatatypeName(), Is.EqualTo("String"));

            var datatypeDefinitionXhtml = new DatatypeDefinitionXHTML();

            Assert.That(datatypeDefinitionXhtml.QueryDatatypeName(), Is.EqualTo("XHTML"));
        }
Ejemplo n.º 3
0
        public void Verify_That_The_AttributeDefinition_Can_Be_Set_Or_Get()
        {
            var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration();

            var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration();

            attributeDefinitionEnumeration.Type = datatypeDefinitionEnumeration;

            var attributeDefinition = (AttributeDefinition)attributeDefinitionEnumeration;

            Assert.AreEqual(datatypeDefinitionEnumeration, attributeDefinition.DatatypeDefinition);

            attributeDefinition.DatatypeDefinition = datatypeDefinitionEnumeration;

            Assert.AreEqual(datatypeDefinitionEnumeration, attributeDefinition.DatatypeDefinition);
        }
        public void VerifyThatTheAttributeDefinitionCanBeSetOrGet()
        {
            var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration();

            var attributeDefinitionEnumeration = new AttributeDefinitionEnumeration();

            attributeDefinitionEnumeration.Type = datatypeDefinitionEnumeration;

            var attributeDefinition = (AttributeDefinition)attributeDefinitionEnumeration;

            Assert.AreEqual(datatypeDefinitionEnumeration, attributeDefinition.DatatypeDefinition);

            attributeDefinition.DatatypeDefinition = datatypeDefinitionEnumeration;

            Assert.AreEqual(datatypeDefinitionEnumeration, attributeDefinition.DatatypeDefinition);
        }
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.assembler = new Assembler(this.uri);

            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationSetup = this.iterationSetup
            };

            this.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);
            this.sitedir.Domain.Add(this.domain);
            this.model.Iteration.Add(this.iteration);

            this.person      = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Person = this.person
            };
            this.sitedir.Person.Add(this.person);
            this.modelsetup.Participant.Add(this.participant);

            this.pt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl.ParameterType.Add(this.pt);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) }
            });

            this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.reqIf      = new ReqIF();
            this.reqIf.Lang = "en";
            var corecontent = new ReqIFContent();

            this.reqIf.CoreContent = corecontent;
            this.stringDatadef     = new DatatypeDefinitionString();
            this.boolDatadef       = new DatatypeDefinitionBoolean();
            this.intDatadef        = new DatatypeDefinitionInteger();
            this.realDatadef       = new DatatypeDefinitionReal();
            this.enumDatadef       = new DatatypeDefinitionEnumeration();
            this.enumDatadef.SpecifiedValues.Add(new EnumValue {
                Properties = new EmbeddedValue {
                    Key = 1, OtherContent = "enum1"
                }
            });

            this.dateDatadef = new DatatypeDefinitionDate();

            corecontent.DataTypes.Add(this.stringDatadef);
            corecontent.DataTypes.Add(this.boolDatadef);
            corecontent.DataTypes.Add(this.dateDatadef);
            corecontent.DataTypes.Add(this.enumDatadef);
            corecontent.DataTypes.Add(this.intDatadef);
            corecontent.DataTypes.Add(this.realDatadef);

            this.dialog = new ParameterTypeMappingDialogViewModel(this.reqIf.Lang, corecontent.DataTypes, null, this.iteration, this.session.Object, this.thingDialogNavigationService.Object);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }
        /// <summary>
        /// create all the different <see cref="DatatypeDefinition"/>s
        /// </summary>
        private void CreateDataTypes()
        {
            var reqIfContent = this.reqIF.CoreContent.SingleOrDefault();

            var datatypeDefinitionBoolean = new DatatypeDefinitionBoolean();

            datatypeDefinitionBoolean.Description = "boolean data type definition";
            datatypeDefinitionBoolean.Identifier  = "boolean";
            datatypeDefinitionBoolean.LastChange  = DateTime.Parse("2015-12-01");
            datatypeDefinitionBoolean.LongName    = "a boolean";
            reqIfContent.DataTypes.Add(datatypeDefinitionBoolean);

            var datatypeDefinitionDate = new DatatypeDefinitionDate();

            datatypeDefinitionDate.Description = "date data type definition";
            datatypeDefinitionDate.Identifier  = "DateTime";
            datatypeDefinitionDate.LastChange  = DateTime.Parse("2015-12-01");
            datatypeDefinitionDate.LongName    = "a date";
            reqIfContent.DataTypes.Add(datatypeDefinitionDate);

            var datatypeDefinitionEnumeration = new DatatypeDefinitionEnumeration();

            datatypeDefinitionEnumeration.Description = "enum value type definition";
            datatypeDefinitionEnumeration.Identifier  = this.enumdatatype_id;
            datatypeDefinitionEnumeration.LastChange  = DateTime.Parse("2015-12-01");
            datatypeDefinitionEnumeration.LongName    = "an enumeration";

            var enumValuelow = new EnumValue();

            enumValuelow.Identifier = this.enum_value_low_id;
            enumValuelow.LastChange = DateTime.Parse("2015-12-01");
            enumValuelow.LongName   = "low";

            var embeddedValueLow = new EmbeddedValue();

            embeddedValueLow.Key          = 1;
            embeddedValueLow.OtherContent = "foo";
            enumValuelow.Properties       = embeddedValueLow;

            var enumValuemedium = new EnumValue();

            enumValuemedium.Identifier = this.enum_value_medium_id;
            enumValuemedium.LastChange = DateTime.Parse("2015-12-01");
            enumValuemedium.LongName   = "medium";

            var embeddedValueMedium = new EmbeddedValue();

            embeddedValueMedium.Key          = 2;
            embeddedValueMedium.OtherContent = "bar";
            enumValuemedium.Properties       = embeddedValueMedium;

            datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuelow);
            datatypeDefinitionEnumeration.SpecifiedValues.Add(enumValuemedium);

            reqIfContent.DataTypes.Add(datatypeDefinitionEnumeration);

            var datatypeDefinitionInteger = new DatatypeDefinitionInteger();

            datatypeDefinitionInteger.Description = "integer data type definition";
            datatypeDefinitionInteger.Identifier  = "integer";
            datatypeDefinitionInteger.LastChange  = DateTime.Parse("2015-12-01");
            datatypeDefinitionInteger.LongName    = "an integer";
            datatypeDefinitionInteger.Min         = 2;
            datatypeDefinitionInteger.Max         = 6;
            reqIfContent.DataTypes.Add(datatypeDefinitionInteger);

            var datatypeDefinitionReal = new DatatypeDefinitionReal();

            datatypeDefinitionReal.Description = "real data type definition";
            datatypeDefinitionReal.Identifier  = "real";
            datatypeDefinitionReal.LastChange  = DateTime.Parse("2015-12-01");
            datatypeDefinitionReal.LongName    = "a real";
            datatypeDefinitionReal.Accuracy    = 5;
            datatypeDefinitionReal.Min         = 1;
            datatypeDefinitionReal.Max         = 5;
            reqIfContent.DataTypes.Add(datatypeDefinitionReal);

            var datatypeDefinitionString = new DatatypeDefinitionString();

            datatypeDefinitionString.Description = "string data type definition";
            datatypeDefinitionString.Identifier  = "string";
            datatypeDefinitionString.LastChange  = DateTime.Parse("2015-12-01");
            datatypeDefinitionString.MaxLength   = 32000;
            datatypeDefinitionString.LongName    = "a string";
            reqIfContent.DataTypes.Add(datatypeDefinitionString);

            var datatypeDefinitionXhtml = new DatatypeDefinitionXHTML();

            datatypeDefinitionXhtml.Description = "string data type definition";
            datatypeDefinitionXhtml.Identifier  = "xhtml";
            datatypeDefinitionXhtml.LastChange  = DateTime.Parse("2015-12-01");
            datatypeDefinitionXhtml.LongName    = "a string";
            reqIfContent.DataTypes.Add(datatypeDefinitionXhtml);
        }