コード例 #1
0
        public void RegexTest()
        {
            var obj = new RegularExpressionAttrTest()
            {
                Country = "uS"
            };

            var res = SwagValidator.Validate(obj); //should throw exception

            Assert.IsTrue(res);
        }
コード例 #2
0
        public void RegexTestNotValid()
        {
            try
            {
                var obj = new RegularExpressionAttrTest()
                {
                    Country = "uX"
                };

                SwagValidator.Validate(obj); //should throw exception
                Assert.Fail();               // should not reach here because empty string threw exception
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("Country is invalid"));
            }
        }