Пример #1
0
        public void Value_With_Multiple_Inserts()
        {
            ITextRepository repo = new DictionaryTextRepository(new TextItem[]
            {
                new TextItem {
                    Key = "abc", Value = "abc abc"
                },
                new TextItem {
                    Key = "def", Value = "def $(abc) def $(abc) def"
                }
            });

            var processor = new IncludeTextProcessor(repo);


            var value = processor.Process("def");

            Assert.AreEqual("def abc abc def abc abc def", value);
        }
Пример #2
0
        public void Circular_Reference_Keys_Ignore_Case_Throws_Exception()
        {
            ITextRepository repo = new DictionaryTextRepository(new TextItem[]
            {
                new TextItem {
                    Key = "aBc", Value = "abc $(def) abc"
                },
                new TextItem {
                    Key = "def", Value = "def $(abc) def"
                }
            });

            var processor = new IncludeTextProcessor(repo);


            var ex = Assert.Throws <InvalidOperationException>(() => processor.Process("def"));

            Console.Write(ex.Message);
        }
Пример #3
0
        public void Value_With_Insert_First_Last_Character()
        {
            ITextRepository repo = new DictionaryTextRepository(new TextItem[]
            {
                new TextItem {
                    Key = "abc", Value = "abc"
                },
                new TextItem {
                    Key = "def", Value = "$(abc)"
                }
            });

            var processor = new IncludeTextProcessor(repo);



            var value = processor.Process("def");

            Assert.AreEqual("abc", value);
        }
Пример #4
0
        public void Invalid_Key_Format_Missing_Key_And_Tail()
        {
            ITextRepository repo = new DictionaryTextRepository(new TextItem[]
            {
                new TextItem {
                    Key = "abc", Value = "123"
                },
                new TextItem {
                    Key = "def", Value = "def"
                },
                new TextItem {
                    Key = "hij", Value = "$($(def)"
                },
                new TextItem {
                    Key = "klm", Value = "$("
                },
                new TextItem {
                    Key = "nop", Value = "$(sdfsdf"
                },
            });

            var processor = new IncludeTextProcessor(repo);



            var value = processor.Process("hij");

            Assert.AreEqual("$(def", value, "Failed to find 'hij'");


            value = processor.Process("klm");

            Assert.AreEqual("$(", value, "Failed to find 'klm'");

            value = processor.Process("nop");

            Assert.AreEqual("$(sdfsdf", value, "Failed to find 'nop'");
        }
Пример #5
0
        public void Invalid_Key_Not_Found()
        {
            ITextRepository repo = new DictionaryTextRepository(new TextItem[]
            {
                new TextItem {
                    Key = "abc", Value = "123"
                },
                new TextItem {
                    Key = "def", Value = "def"
                },
                new TextItem {
                    Key = "hij", Value = "$(xxx)$(def)"
                },
            });

            var processor = new IncludeTextProcessor(repo);



            var value = processor.Process("hij");

            Assert.AreEqual("$(xxx)def", value);
        }