示例#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 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));
            }
        }