Example #1
0
        public void CompositeTest_NoTemplateFile_FileNotFoundException()
        {
            if (File.Exists(System.IO.Path.Combine(Config.Template.TargetTemplate, "RoutesUp.bat")))
            {
                File.Delete(System.IO.Path.Combine(Config.Template.TargetTemplate, "RoutesUp.bat"));
            }

            ScriptGenerater sg = new ScriptGenerater();

            sg.Composite(Config.Template.TargetTemplate, Config.Template.CodeLineRegx, IPs);
        }
Example #2
0
        public void CompositeTest_TemplateFile_Composited()
        {
            string expectation = "@echo off\r\n\r\n"
                                 + "for /F \"tokens=3\" %%* in ('route print ^| findstr \"\\<0.0.0.0\\>\"') do set \"gw=%%*\"\r\n\r\n"
                                 + "IF %gw%==%%* (\r\n  echo Error, connot find gateway\r\n  pause\r\n  exit\r\n)\r\n\r\n"
                                 + "ipconfig /flushdns\r\n\r\n@echo on\r\n\r\n"
                                 + "route add 27.125.204.0 mask 255.255.252.0 %gw% metric 5\r\n"
                                 + "route add 27.126.64.0 mask 255.255.192.0 %gw% metric 5\r\n"
                                 + "route add 27.126.128.0 mask 255.255.240.0 %gw% metric 5\r\n\r\n";

            ScriptGenerater sg     = new ScriptGenerater();
            string          result = sg.Composite(Config.TestData.TemplateFile,
                                                  Config.Template.CodeLineRegx,
                                                  IPs);

            Assert.IsTrue(result.Equals(expectation));
        }