internal static void ValidateEquals(ToolTaskExtension t, string lookFor, bool useResponseFile) { CommandLineBuilderExtension b = new CommandLineBuilderExtension(); if (useResponseFile) { t.AddResponseFileCommands(b); } else { t.AddCommandLineCommands(b); } string cl = b.ToString(); string msg = String.Format("Command-line = [{0}]\r\n", cl); msg += String.Format("Expected = [{0}]\r\n", lookFor); if (cl != lookFor) { msg += "Does not match!\r\n"; Console.WriteLine(msg); Assert.True(false, msg); } }
internal static void ValidateContains(ToolTaskExtension t, string lookFor, bool useResponseFile) { CommandLineBuilderExtension b = new CommandLineBuilderExtension(); if (useResponseFile) { t.AddResponseFileCommands(b); } else { t.AddCommandLineCommands(b); } string cl = b.ToString(); string msg = String.Format("Command-line = [{0}]\r\n", cl); msg += String.Format(" Searching for [{0}]\r\n", lookFor); if (cl.IndexOf(lookFor) == -1) { msg += "Not found!\r\n"; Console.WriteLine(msg); Assert.True(false, msg); } }
internal static void ValidateNoParameterStartsWith( ToolTaskExtension t, string startsWith, string except, bool useResponseFile ) { CommandLineBuilderExtension b = new CommandLineBuilderExtension(); if (useResponseFile) { t.AddResponseFileCommands(b); } else { t.AddCommandLineCommands(b); } string cl = b.ToString(); string msg = String.Format("Command-line = [{0}]\r\n", cl); msg += String.Format(" Searching for something that starts with [{0}]\r\n", startsWith); msg += String.Format(" that doesn't contain [{0}]\r\n", except); string[] pieces = Parse(cl); foreach (string s in pieces) { msg += String.Format(" Parm = [{0}]\r\n", s); if (s.Length < startsWith.Length) { // Skip anything shorter than the compare string. continue; } if (String.Equals(s.Substring(0, startsWith.Length), startsWith, StringComparison.OrdinalIgnoreCase)) { // If this doesn't match the 'except' then this is an error. if (!String.Equals(s, except, StringComparison.Ordinal)) { msg += String.Format(" Found something!\r\n"); Console.WriteLine(msg); Assert.True(false, msg); // Found the startsWith but shouldn't have. return; } } } }
internal static string GetCommandLine(ToolTaskExtension t, bool useResponseFile) { CommandLineBuilderExtension b = new CommandLineBuilderExtension(); if (useResponseFile) { t.AddResponseFileCommands(b); } else { t.AddCommandLineCommands(b); } return(b.ToString()); }
internal static int ValidateHasParameter(ToolTaskExtension t, string parameter, bool useResponseFile) { CommandLineBuilderExtension b = new CommandLineBuilderExtension(); if (useResponseFile) { t.AddResponseFileCommands(b); } else { t.AddCommandLineCommands(b); } string cl = b.ToString(); string msg = String.Format("Command-line = [{0}]\r\n", cl); msg += String.Format(" Searching for [{0}]\r\n", parameter); string[] pieces = Parse(cl); int i = 0; foreach (string s in pieces) { msg += String.Format(" Parm = [{0}]\r\n", s); if (s == parameter) { return(i); } i++; } msg += "Not found!\r\n"; Console.WriteLine(msg); Assert.True(false, msg); // Could not find the parameter. return(0); }
internal static int ValidateHasParameter(ToolTaskExtension t, string parameter) { return(ValidateHasParameter(t, parameter, true /* use response file */)); }
internal static void ValidateNoParameterStartsWith(ToolTaskExtension t, string startsWith, string except) { ValidateNoParameterStartsWith(t, startsWith, except, true); }
internal static void ValidateNoParameterStartsWith(ToolTaskExtension t, string startsWith, bool useResponseFile) { ValidateNoParameterStartsWith(t, startsWith, "", useResponseFile); }