Beispiel #1
0
        public void TextObjectAddToTest()
        {
            var testObj  = new TextObject("abc");
            var objToAdd = new TextObject("def");

            testObj.AddAt(objToAdd, ".*()$");
            Assert.AreEqual("abcdef", testObj.Serialize());
            testObj.AddAt(objToAdd, "^()");
            Assert.AreEqual("defabcdef", testObj.Serialize());
        }
Beispiel #2
0
        public void TextObjectSetPropertyTest()
        {
            const string source     = "abc=123; def=789";
            var          textObject = new TextObject(source);

            // replace the first occurrence of = followed by a number of digits
            Assert.IsTrue(textObject.SetProperty("(?:=(\\d+))", "456"));
            Assert.AreEqual("abc=456; def=789", textObject.Serialize());

            // regex should not match, so it should not change anything
            Assert.IsFalse(textObject.SetProperty("(?:ghi=(\\d+))", "456"));
            Assert.AreEqual("abc=456; def=789", textObject.Serialize());
        }
Beispiel #3
0
        public void TextObjectDeleteTest()
        {
            const string source     = "abc=123; def=789";
            var          textObject = new TextObject(source);

            Assert.IsTrue(textObject.Delete("(abc=123; )"));
            Assert.AreEqual("def=789", textObject.Serialize());
        }