예제 #1
0
        public void TestNullEmptyBefore()
        {
            var function = new RegExReplaceFunction();

            try
            {
                function.Evaluate("abcdef", null, "-");
                Assert.Fail("Expected exception");
            }
            catch (ArgumentException)
            {
                //oke
            }
        }
예제 #2
0
        public void TestNullAll()
        {
            var function = new RegExReplaceFunction();

            try
            {
                function.Evaluate(null, null, null);
                Assert.Fail("Expected exception");
            }
            catch (ArgumentException)
            {
                //oke
            }
        }
예제 #3
0
        public void ComplexPattern()
        {
            var function = new RegExReplaceFunction();
            var pattern  = @"(^\+)|(^00)|(\ |\(|\)|\-)";

            Assert.That(function.Evaluate("0614664954", pattern, ""), Is.EqualTo("0614664954"));
            Assert.That(function.Evaluate("+31614664954", pattern, ""), Is.EqualTo("31614664954"));
            Assert.That(function.Evaluate("061+4664954", pattern, ""), Is.EqualTo("061+4664954"));
            Assert.That(function.Evaluate("0031614664954", pattern, ""), Is.EqualTo("31614664954"));
            Assert.That(function.Evaluate("0031614664954", pattern, ""), Is.EqualTo("31614664954"));
            Assert.That(function.Evaluate("06 14 66 49 54", pattern, ""), Is.EqualTo("0614664954"));
            Assert.That(function.Evaluate("(06) 14 66 49 54", pattern, ""), Is.EqualTo("0614664954"));
            Assert.That(function.Evaluate("06-14664954", pattern, ""), Is.EqualTo("0614664954"));
        }
예제 #4
0
        public void TestNullSource()
        {
            var function = new RegExReplaceFunction();

            Assert.That(function.Evaluate(null, "a", "b"), Is.EqualTo(""));
        }
예제 #5
0
        public void TestNullEmptyAfter()
        {
            var function = new RegExReplaceFunction();

            Assert.That(function.Evaluate("a-b-c-d-e-f", "-", null), Is.EqualTo("abcdef"));
        }
예제 #6
0
        public void TestAllFilled()
        {
            var function = new RegExReplaceFunction();

            Assert.That(function.Evaluate("a-b-c-d-e-f", "-", "+"), Is.EqualTo("a+b+c+d+e+f"));
        }