Exemplo n.º 1
0
        public void TestNullEmptyBefore()
        {
            var function = new RegExReplaceFunction();

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

            try
            {
                function.Evaluate(null, null, null);
                Assert.Fail("Expected exception");
            }
            catch (ArgumentException)
            {
                //oke
            }
        }
Exemplo n.º 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"));
        }
Exemplo n.º 4
0
        public void TestNullSource()
        {
            var function = new RegExReplaceFunction();

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

            Assert.That(function.Evaluate("a-b-c-d-e-f", "-", null), Is.EqualTo("abcdef"));
        }
Exemplo n.º 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"));
        }