示例#1
0
        public virtual void testgetMatchingElementsFromParentMulti()
        {
            JDFDoc    ddc = new JDFDoc("DevCap");
            JDFDoc    dde = new JDFDoc("Layout");
            JDFDevCap dc  = (JDFDevCap)ddc.getRoot();
            JDFLayout e   = (JDFLayout)dde.getRoot();

            for (int i = 0; i < 2; i++)
            {
                JDFDevCap dc1 = dc.appendDevCap();
                dc1.setName("Media");
                dc1.setMaxOccurs(1);
                dc1.setMinOccurs(1);
                JDFEnumerationState es = dc1.appendEnumerationState("MediaType");
                string mediaType       = i == 0 ? "Paper" : "Plate";
                es.setAllowedValueList(new VString(mediaType, null));

                e.appendElement("Media").setAttribute("MediaType", mediaType);
            }
            VElement devCapVector = dc.getDevCapVector(null, true);

            for (int i = 0; i < 2; i++)
            {
                VElement vMatch = ((JDFDevCap)devCapVector.item(i)).getMatchingElementsFromParent(e, devCapVector);
                Assert.AreEqual(1, vMatch.Count);
                Assert.AreEqual(e.getElement("Media", null, i), vMatch.item(0));
            }
        }
示例#2
0
        public virtual void testEnumerationState()
        {
            JDFDoc d = new JDFDoc("EnumerationState");
            JDFEnumerationState es = (JDFEnumerationState)d.getRoot();
            VString             v  = new VString();

            v.Add("foo");
            v.Add("bar");

            es.setAllowedValueList(v);
            Assert.IsTrue(es.fitsValue("foo", EnumFitsValue.Allowed));
            Assert.IsTrue(es.fitsValue("bar", EnumFitsValue.Allowed));
            Assert.IsFalse(es.fitsValue("fnarf", EnumFitsValue.Allowed));

            es.setListType(EnumListType.List);
            Assert.IsTrue(es.fitsValue("foo", EnumFitsValue.Allowed));
            Assert.IsTrue(es.fitsValue("foo bar", EnumFitsValue.Allowed));
            Assert.IsTrue(es.fitsValue("foo bar foo", EnumFitsValue.Allowed));
            Assert.IsFalse(es.fitsValue("foo bar fnarf", EnumFitsValue.Allowed));

            es.setListType(EnumListType.CompleteList);
            Assert.IsFalse(es.fitsValue("foo", EnumFitsValue.Allowed));
            Assert.IsTrue(es.fitsValue("foo bar", EnumFitsValue.Allowed));
            Assert.IsTrue(es.fitsValue("bar foo", EnumFitsValue.Allowed));
            Assert.IsFalse(es.fitsValue("foo bar foo", EnumFitsValue.Allowed));
            Assert.IsFalse(es.fitsValue("foo bar fnarf", EnumFitsValue.Allowed));

            // TODO implement more list types
            // es.setListType(EnumListType.OrderedList);
            // Assert.IsFalse(es.fitsValue("foo", EnumFitsValue.Allowed));
            // Assert.IsTrue(es.fitsValue("foo bar", EnumFitsValue.Allowed));
            // Assert.IsFalse(es.fitsValue("bar foo", EnumFitsValue.Allowed));
            // Assert.IsFalse(es.fitsValue("foo bar foo", EnumFitsValue.Allowed));
            // Assert.IsFalse(es.fitsValue("foo bar fnarf", EnumFitsValue.Allowed));
        }
示例#3
0
        public override void setUp()
        {
            base.setUp();
            JDFElement.setLongID(false);

            JDFDoc doc = new JDFDoc("Device");

            device = (JDFDevice)doc.getRoot();

            devicecap = device.appendDeviceCap();
            devicecap.setCombinedMethod(EnumCombinedMethod.None);
            devicecap.setTypeExpression("(fnarf)|(blub)");
            devicecap.setTypes(new VString("fnarf blub", null));
            JDFDevCapPool dcp = devicecap.appendDevCapPool();
            JDFDevCaps    dcs = devicecap.appendDevCaps();

            dcs.setContext(EnumContext.Resource);
            dcs.setName("Component");
            dcs.setRequired(true);
            JDFDevCap dc = dcp.appendDevCap();

            dc.setID("dc_Component");
            dcs.setDevCapRef(dc);
            compState = dc.appendEnumerationState("ComponentType");
            ptState   = dc.appendNameState("ProductType");
        }
示例#4
0
        public virtual void testGetEnumerationState()
        {
            JDFDoc              d  = new JDFDoc("DevCap");
            JDFDevCap           dc = (JDFDevCap)d.getRoot();
            JDFEnumerationState es = dc.appendEnumerationState("foo");

            Assert.AreEqual("foo", es.getName());
            es = dc.getEnumerationState("bar");
            Assert.IsNull(es);
            es = dc.getCreateEnumerationState("bar");
            Assert.IsNotNull(es);
            Assert.AreEqual("bar", es.getName());
            es = dc.getEnumerationState("bar");
            Assert.IsNotNull(es);
            Assert.AreEqual("bar", es.getName());
        }
示例#5
0
        public virtual void testRegExp()
        {
            for (int i = 0; i < 2; i++)
            {
                JDFDoc d = new JDFDoc("EnumerationState");
                JDFEnumerationState es = (JDFEnumerationState)d.getRoot();

                es.setListType(EnumListType.List);
                es.setAllowedRegExp("a b( c)?( d)*");
                if (i == 1)
                {
                    es.setAllowedValueList(new VString("a b c d", " "));
                }
                Assert.IsTrue(es.fitsValue("a b", EnumFitsValue.Allowed));
                Assert.IsTrue(es.fitsValue("a b c", EnumFitsValue.Allowed));
                Assert.IsTrue(es.fitsValue("a b c d d", EnumFitsValue.Allowed));
                Assert.IsFalse(es.fitsValue("a b c c", EnumFitsValue.Allowed));
                Assert.IsFalse(es.fitsValue("a c b", EnumFitsValue.Allowed));
                Assert.IsFalse(es.fitsValue("abc", EnumFitsValue.Allowed));
                Assert.IsFalse(es.fitsValue("A b c", EnumFitsValue.Allowed));
            }
        }