예제 #1
0
        public void EqualsSignInSearchReplaceString_WillReturnStringWithEqual()
        {
            string argument = @"/O=av/F=something/S=""hello=world how are you""/R=""hello world = "" how are you? """"";

            ISearchReplaceParameter argParser = TestHelper.GetApplicationParameters(argument);

            Assert.AreEqual(@"hello=world how are you", argParser.GetSearchString()[0]);
            Assert.AreEqual(@"hello world = "" how are you? """, argParser.GetReplaceString()[0]);
        }
예제 #2
0
 public SearchReplaceFileReplacer(ISearchReplaceParameter parameters)
 {
     _Replacer = new XmlSearchReplace(
         parameters.GetLocationOptions()
         , parameters.GetOperationOptions()
         , parameters.GetSearchString()
         , parameters.GetReplaceString());
     this._Parameters = parameters;
     _Document        = new XmlDocument();
 }
예제 #3
0
        public void CheckSearchStringReplaceFileName_WithSurroundingDoubleQutoesAndSpaceInsideQuotes_ShouldNotTrimAndGiveStringWithoutQuotes()
        {
            string argument = @"/S=  "" hello world ""   /R=   "" how are you ""   /F=   "" c:\documents and settings\blah blah.html ""   /O=av";

            ISearchReplaceParameter argParser = TestHelper.GetApplicationParameters(argument);

            Assert.AreEqual(" hello world ", argParser.GetSearchString()[0]);
            Assert.AreEqual(" how are you ", argParser.GetReplaceString()[0]);
            Assert.AreEqual(" c:\\documents and settings\\blah blah.html ", argParser.GetFileName());
        }
예제 #4
0
        public void CheckSearchStringReplaceFileName_WithSpaceBeforeAndAfterWithoutSurroundingDoubleQutoes_ShouldTrimInput()
        {
            string argument = "/S= hello world /R= how are you /F=  c:\\documents and settings\\blah blah.html  /O=av";

            ISearchReplaceParameter argParser = TestHelper.GetApplicationParameters(argument);

            Assert.AreEqual("hello world", argParser.GetSearchString()[0]);
            Assert.AreEqual("how are you", argParser.GetReplaceString()[0]);
            Assert.AreEqual("c:\\documents and settings\\blah blah.html", argParser.GetFileName());
        }
예제 #5
0
        public void CheckArgumentsAreFineWithActualValue()
        {
            string[] args = { "/O=", "av,ev,en,an,ve,va", "/S=\\\\server04\\spfiles", "/R=L:", "/F=c:\\documents", "and", "settings\\desktop\\file.xml" };

            ISearchReplaceParameter argParser = TestHelper.GetParameters(args);

            Assert.AreEqual(SearchReplaceLocationOptions.ReplaceAll, argParser.GetLocationOptions());
            Assert.AreEqual("c:\\documents and settings\\desktop\\file.xml", argParser.GetFileName());
            Assert.AreEqual("\\\\server04\\spfiles", argParser.GetSearchString()[0]);
            Assert.AreEqual("L:", argParser.GetReplaceString()[0]);
        }
예제 #6
0
        public void StringArgumentsWithMoreThanOneEqualsSignShouldWork()
        {
            string[] args = { "/O=", "av,ev,en,an,va,ve", @"/R==", "/F=c:\\documents", "and", "settings\\desktop\\file.xml", "/S=Equals /W /i /c" };

            ISearchReplaceParameter parameters = TestHelper.GetParameters(args);

            Assert.AreEqual(SearchReplaceLocationOptions.ReplaceAll, parameters.GetLocationOptions());
            Assert.AreEqual("c:\\documents and settings\\desktop\\file.xml", parameters.GetFileName());
            Assert.AreEqual("Equals", parameters.GetSearchString()[0]);
            Assert.AreEqual("=", parameters.GetReplaceString()[0]);
            Assert.AreEqual(SearchReplaceOperationOptions.CaseInsensitive | SearchReplaceOperationOptions.WholeWordOnly, parameters.GetOperationOptions());
            Assert.AreEqual(true, parameters.ContinueOnError);
        }
예제 #7
0
        public void CheckArgumentsAreFine()
        {
            string[] args = { "/O=", "av,ev,en,an,va,ve", "/R=replace ", "/F=c:\\documents", "and", "settings\\desktop\\file.xml", "/S=search /W /i /c" };

            ISearchReplaceParameter param = TestHelper.GetParameters(args);

            Assert.AreEqual(SearchReplaceLocationOptions.ReplaceAll, param.GetLocationOptions());
            Assert.AreEqual("c:\\documents and settings\\desktop\\file.xml", param.GetFileName());
            Assert.AreEqual("search", param.GetSearchString()[0]);
            Assert.AreEqual("replace", param.GetReplaceString()[0]);
            Assert.AreEqual(SearchReplaceOperationOptions.CaseInsensitive | SearchReplaceOperationOptions.WholeWordOnly, param.GetOperationOptions());
            Assert.AreEqual(true, param.ContinueOnError);
        }
예제 #8
0
        public void LParamInCommandWithParamFile_WillIgnoreLParamInCommandLine()
        {
            string paramFile = TestHelper.CreateParameterFile(new string[] { "/S=hello /R=world", "/S=Good /L" });
            string argument  = String.Format(@"/F=something /P=""{0}"" /L", paramFile);

            ISearchReplaceParameter argParser = TestHelper.GetApplicationParameters(argument);

            Assert.AreEqual(@"hello", argParser.GetSearchString()[0]);
            Assert.AreEqual(@"world", argParser.GetReplaceString()[0]);
            Assert.AreEqual(@"Good", argParser.GetSearchString()[1]);
            Assert.AreEqual(@"good", argParser.GetReplaceString()[1]);

            TestHelper.DeleteLastParameterFile();
        }