예제 #1
0
        public void Validation_MandatoryDateTimeTest()
        {
            EAny def = new EAny()
            {
                DataType  = DataType.DT,
                ReqDes    = RequirementDesignator.Mandatory,
                MinLength = 6,
                MaxLength = 6,
            };

            EAny def2 = new EAny()
            {
                DataType  = DataType.TM,
                ReqDes    = RequirementDesignator.Mandatory,
                MinLength = 4,
                MaxLength = 8,
            };

            var el = new EdiSimpleDataElement(def, "");

            Assert.IsFalse(el.IsValid(def));

            el = new EdiSimpleDataElement(def, null);
            Assert.IsFalse(el.IsValid(def));

            el = new EdiSimpleDataElement(def2, "");
            Assert.IsFalse(el.IsValid(def2));

            el = new EdiSimpleDataElement(def2, null);
            Assert.IsFalse(el.IsValid(def2));
        }
예제 #2
0
        public void Validation_OptionalDateTimeTest()
        {
            EAny def = new EAny()
            {
                DataType  = DataType.DT,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 6,
                MaxLength = 6,
            };

            EAny def2 = new EAny()
            {
                DataType  = DataType.DT,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 8,
                MaxLength = 8,
            };

            EAny def3 = new EAny()
            {
                DataType  = DataType.TM,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 4,
                MaxLength = 4,
            };

            var el = new EdiSimpleDataElement(def, "160102");

            Assert.IsTrue(el.IsValid(def));

            el = new EdiSimpleDataElement(def, "125566");
            Assert.IsFalse(el.IsValid(def));

            el = new EdiSimpleDataElement(def, "");
            Assert.IsTrue(el.IsValid(def));

            el = new EdiSimpleDataElement(def2, "20160102");
            Assert.IsTrue(el.IsValid(def2));

            el = new EdiSimpleDataElement(def2, "22125566");
            Assert.IsFalse(el.IsValid(def2));

            el = new EdiSimpleDataElement(def2, "");
            Assert.IsTrue(el.IsValid(def2));

            el = new EdiSimpleDataElement(def3, "1122");
            Assert.IsTrue(el.IsValid(def3));

            el = new EdiSimpleDataElement(def3, "4567");
            Assert.IsFalse(el.IsValid(def3));

            el = new EdiSimpleDataElement(def3, "");
            Assert.IsTrue(el.IsValid(def3));

            el = new EdiSimpleDataElement(def3, "1526");
            Assert.IsTrue(el.IsValid(def3));
        }
예제 #3
0
        public void Validation_NumericTest()
        {
            EAny def = new EAny()
            {
                DataType  = DataType.N0,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 3,
                MaxLength = 6,
            };

            EAny def2 = new EAny()
            {
                DataType  = DataType.N1,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 3,
                MaxLength = 6,
            };

            EAny def3 = new EAny()
            {
                DataType  = DataType.R,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 3,
                MaxLength = 6,
            };

            var el = new EdiDataElement(def, "123");

            Assert.IsTrue(el.IsValid(def));

            el = new EdiDataElement(def, "12c");
            Assert.IsFalse(el.IsValid(def));

            el = new EdiDataElement(def, "");
            Assert.IsTrue(el.IsValid(def));

            el = new EdiDataElement(def2, "123");
            Assert.IsTrue(el.IsValid(def2));

            el = new EdiDataElement(def2, "12c");
            Assert.IsFalse(el.IsValid(def2));

            el = new EdiDataElement(def2, "");
            Assert.IsTrue(el.IsValid(def2));

            el = new EdiDataElement(def3, "123.23");
            Assert.IsTrue(el.IsValid(def3));

            el = new EdiDataElement(def3, "1233c");
            Assert.IsFalse(el.IsValid(def3));

            el = new EdiDataElement(def3, "");
            Assert.IsTrue(el.IsValid(def3));
        }
예제 #4
0
        public void Validation_BinaryTest()
        {
            EAny def = new EAny()
            {
                DataType  = DataType.B,
                MinLength = 1,
                MaxLength = 100,
                ReqDes    = RequirementDesignator.Optional
            };

            var el = new EdiSimpleDataElement(def, "!@#@$$@$!");

            Assert.IsTrue(el.IsValid(def));
        }
예제 #5
0
        public void Validation_OptionalTimeTest()
        {
            EAny def = new EAny()
            {
                DataType  = DataType.TM,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 4,
                MaxLength = 4,
            };

            EAny def2 = new EAny()
            {
                DataType  = DataType.TM,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 4,
                MaxLength = 8,
            };

            var el = new EdiSimpleDataElement(def, "1122");

            Assert.IsTrue(el.IsValid(def));

            el = new EdiSimpleDataElement(def, "4567");
            Assert.IsFalse(el.IsValid(def));

            el = new EdiSimpleDataElement(def, "");
            Assert.IsTrue(el.IsValid(def));

            el = new EdiSimpleDataElement(def, "1526");
            Assert.IsTrue(el.IsValid(def));

            el = new EdiSimpleDataElement(def, "152605");
            Assert.IsFalse(el.IsValid(def));

            el = new EdiSimpleDataElement(def2, "0105");
            Assert.IsTrue(el.IsValid(def2));

            el = new EdiSimpleDataElement(def2, "101525");
            Assert.IsTrue(el.IsValid(def2));

            el = new EdiSimpleDataElement(def2, "1105355");
            Assert.IsTrue(el.IsValid(def2));

            el = new EdiSimpleDataElement(def2, "11053559");
            Assert.IsTrue(el.IsValid(def2));
        }
예제 #6
0
        public void Validation_IdTest()
        {
            EAny def = new EAny()
            {
                DataType  = DataType.ID,
                MinLength = 1,
                MaxLength = 1,
                ReqDes    = RequirementDesignator.Optional
            };

            def.AllowedValues.AddRange(new[] { "C", "F", "N", "R" });

            var el = new EdiDataElement(def, "F");

            Assert.IsTrue(el.IsValid(def));

            el = new EdiDataElement(def, "Z");
            Assert.IsFalse(el.IsValid(def));

            el = new EdiDataElement(def, "");
            Assert.IsTrue(el.IsValid(def));
        }
예제 #7
0
        public void Validation_OptionalMinMaxLen()
        {
            EAny def = new EAny()
            {
                DataType  = DataType.AN,
                ReqDes    = RequirementDesignator.Optional,
                MinLength = 2,
                MaxLength = 5,
            };

            var el = new EdiDataElement(def, "");

            Assert.IsTrue(el.IsValid(def));

            el = new EdiDataElement(def, "a");
            Assert.IsFalse(el.IsValid(def));

            el = new EdiDataElement(def, "abcdefg");
            Assert.IsFalse(el.IsValid(def));

            el = new EdiDataElement(def, "abcde");
            Assert.IsTrue(el.IsValid(def));
        }