示例#1
0
        public void DictionaryToTreeConverter_Test7()
        {
            var dic = new Dictionary <string, string>
            {
                { string.Empty, "X" }
            };

            var tree = DictionaryToTreeConverter.Convert(dic, out var maxLen);

            Assert.IsNull(tree);
        }
示例#2
0
        public void DictionaryToTreeConverter_Test6()
        {
            var dic = new Dictionary <string, string>
            {
                { "A", string.Empty }
            };

            var tree = DictionaryToTreeConverter.Convert(dic, out var maxLen);

            var str = "A";

            var result = PrepareStreams(str,
                                        (data, target) => { ReplaceLogic.V1.ReplaceLogic.ReplaceFile(data, target, tree, maxLen); });

            Assert.AreEqual(string.Empty, result);
        }
示例#3
0
        public void DictionaryToTreeConverter_Test2()
        {
            var dic = new Dictionary <string, string>
            {
                { "IKLM", "MLKI" },
                { "NO", "ON" },
                { "RS", "SR" },
                { "Z", "A" },
                { "A", "Z" }
            };

            var tree = DictionaryToTreeConverter.Convert(dic, out var maxLen);

            var str = "ABCDEFGHIKLMNOPQRSTVXYZ";

            var result = PrepareStreams(str,
                                        (data, target) => { ReplaceLogic.V1.ReplaceLogic.ReplaceFile(data, target, tree, 10, true); });

            Assert.AreEqual("ZBCDEFGHMLKIONPQSRTVXYA", result);
        }
示例#4
0
        public void DictionaryToTreeConverter_Test4()
        {
            var dic = new Dictionary <string, string>
            {
                { "A", "A" },
                { "B", "B" },
                { "C", "S" },
                { "S", "C" },
                { "Z", "ZZ" }
            };

            var tree = DictionaryToTreeConverter.Convert(dic, out var maxLen);

            var str = "ABCDEFGHIKLMNOPQRSTVXYZ";

            var result = PrepareStreams(str,
                                        (data, target) => { ReplaceLogic.V1.ReplaceLogic.ReplaceFile(data, target, tree, 10, true); });

            Assert.AreEqual("ABSDEFGHIKLMNOPQRCTVXYZZ", result);
        }
示例#5
0
        public void DictionaryToTreeConverter_Test1()
        {
            var dic = new Dictionary <string, string>
            {
                { "env.name", "test1" },
                { "env.ver", "1.0" },
                { "env.ver.name", "alfa" },
                { "sys.dir.temp", "c:\\temp" },
                { "sys.dir.win", "c:\\windows" },
                { "net.protocol", "http" },
                { "net.product", "sh" }
            };

            var tree = DictionaryToTreeConverter.Convert(dic, out var maxLen);

            var str = "net.protocol:net.product env.name env.ver (env.ver.name)";

            var result = PrepareStreams(str,
                                        (data, target) => { ReplaceLogic.V1.ReplaceLogic.ReplaceFile(data, target, tree, maxLen); });

            Assert.AreEqual("http:sh test1 1.0 (alfa)", result);
        }