Exemplo n.º 1
0
        public void GenerateConstTest()
        {
            var prg = new RequestGenerator(new Dictionary <string, string[]>());
            var req = new string[] { "test", "testtest", "QWERTY", "", "}", "$}{", "{}" };

            prg.InitIterator();
            prg.ParseRequest(req);
            GenerateTestUnit(ref prg, true, req);
            GenerateTestUnit(ref prg, false);
        }
Exemplo n.º 2
0
        public void GenerateUninitializedDictionaryTest()
        {
            var req = new string[] { "abcabc" };
            var rg  = new RequestGenerator();

            rg.InitIterator();
            rg.ParseRequest(req);
            var ex = Assert.Throws <GenerateException>(() => { GenerateTestUnit(ref rg, true); });

            Assert.That(ex.Message == "Uninitialized Dictionary");
        }
Exemplo n.º 3
0
        public void GenerateUndefinedTest()
        {
            var dict = dict1;
            var req  = new string[] { "abcabc${noexists}" };
            var rg   = new RequestGenerator();

            rg.InitIterator();
            rg.ErrorByUndefinedVar = true;
            rg.dict = dict;
            rg.ParseRequest(req);
            var ex = Assert.Throws <GenerateException>(() => { GenerateTestUnit(ref rg, true); });

            Assert.That(ex.Message == "Undefined variable noexists");
        }
Exemplo n.º 4
0
        public void GenerateVariableTest1()
        {
            var dict = dict1;
            var req  = new string[] { "test${abc}qqq${help}eee" };
            var rg   = new RequestGenerator();

            rg.InitIterator();
            rg.dict = dict;
            rg.ParseRequest(req);
            GenerateTestUnit(ref rg, true, new string[] { $"test{dict["abc"][0]}qqq{dict["help"][0]}eee" });
            GenerateTestUnit(ref rg, true, new string[] { $"test{dict["abc"][1]}qqq{dict["help"][1]}eee" });
            GenerateTestUnit(ref rg, true, new string[] { $"test{dict["abc"][2]}qqq{dict["help"][2]}eee" });
            GenerateTestUnit(ref rg, true, new string[] { $"testqqq{dict["help"][3]}eee" });
            GenerateTestUnit(ref rg, false, new string[] { });
        }
Exemplo n.º 5
0
        public void GenerateIgnoreUndefinedTest()
        {
            var dict = dict1;
            var req  = new string[] { "abcabc${abc}test${num}" };
            var rg   = new RequestGenerator();

            rg.InitIterator();
            rg.ErrorByUndefinedVar = false;
            rg.dict = dict;
            rg.ParseRequest(req);
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc{dict["abc"][0]}test" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc{dict["abc"][1]}test" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc{dict["abc"][2]}test" });
            GenerateTestUnit(ref rg, false);
        }
Exemplo n.º 6
0
        public void GenerateEnumTest()
        {
            var req = new string[] { "abc#{1-9}def" };
            var rg  = new RequestGenerator();

            rg.InitIterator();
            rg.dict = null;
            rg.ParseRequest(req);
            GenerateTestUnit(ref rg, true, new string[] { "abc1def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc2def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc3def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc4def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc5def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc6def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc7def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc8def" });
            GenerateTestUnit(ref rg, true, new string[] { "abc9def" });
            GenerateTestUnit(ref rg, false);
        }
Exemplo n.º 7
0
        public void GenerateVariableTest2()
        {
            var dict = dict3;
            var req  = new string[] { "abcabc${xss}", "test${num}" };
            var rg   = new RequestGenerator();

            rg.InitIterator();
            rg.dict = dict;
            rg.ParseRequest(req);
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc{dict["xss"][0]}", $"test{dict["num"][0]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][1]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][2]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][3]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][4]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][5]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][6]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][7]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"abcabc", $"test{dict["num"][8]}" });
            GenerateTestUnit(ref rg, false);
        }
Exemplo n.º 8
0
        public void GenerateTest()
        {
            var dict = dict4;
            var rg   = new RequestGenerator(dict);
            var req  = new string[] { "My color part #{10-11}:${color}", "number:#{1-8}#{8-0}", "tag:${tag}" };

            rg.InitIterator();
            rg.ParseRequest(req);
            GenerateTestUnit(ref rg, true,
                             new string[] { $"My color part 10:{dict["color"][0]}", $"number:18", $"tag:{dict["tag"][0]}" });
            GenerateTestUnit(ref rg, true,
                             new string[] { $"My color part 11:{dict["color"][1]}", $"number:27", $"tag:{dict["tag"][1]}" });
            GenerateTestUnit(ref rg, true,
                             new string[] { $"My color part :{dict["color"][2]}", $"number:36", $"tag:{dict["tag"][2]}" });
            GenerateTestUnit(ref rg, true,
                             new string[] { $"My color part :{dict["color"][3]}", $"number:45", $"tag:{dict["tag"][3]}" });
            GenerateTestUnit(ref rg, true, new string[] { $"My color part :{dict["color"][4]}", $"number:54", $"tag:" });
            GenerateTestUnit(ref rg, true, new string[] { $"My color part :{dict["color"][5]}", $"number:63", $"tag:" });
            GenerateTestUnit(ref rg, true, new string[] { $"My color part :", $"number:72", $"tag:" });
            GenerateTestUnit(ref rg, true, new string[] { $"My color part :", $"number:81", $"tag:" });
            GenerateTestUnit(ref rg, true, new string[] { $"My color part :", $"number:0", $"tag:" });
            GenerateTestUnit(ref rg, false);
        }