예제 #1
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));
        }
예제 #2
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));
            }
        }
예제 #3
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));
            }
        }