protected static async Task <string> RunTestScript(string scriptText, string baseAddress) { LoggingConsoleManagerDecorator console = new LoggingConsoleManagerDecorator(new NullConsoleManager()); NullPreferences preferences = new NullPreferences(); using (var script = new TestScript(scriptText)) { await new Program().Start($"run {script.FilePath}".Split(' '), console, preferences); } string output = console.LoggedOutput; // remove the first line because it has the randomly generated script file name. output = output.Substring(output.IndexOf(Environment.NewLine) + Environment.NewLine.Length); output = NormalizeOutput(output, baseAddress); return(output); }
protected static HttpState GetHttpState(out MockedFileSystem fileSystem, out IPreferences preferences, string baseAddress = "", string header = "", string path = "", IDictionary <string, string> urlsWithResponse = null, bool readFromFile = false, string fileContents = "", string contentType = "") { HttpResponseMessage responseMessage = new HttpResponseMessage(); responseMessage.Content = new MockHttpContent(string.Empty); MockHttpMessageHandler messageHandler = new MockHttpMessageHandler(urlsWithResponse, header, readFromFile, fileContents, contentType); HttpClient httpClient = new HttpClient(messageHandler); fileSystem = new MockedFileSystem(); preferences = new NullPreferences(); HttpState httpState = new HttpState(fileSystem, preferences, httpClient); if (!string.IsNullOrWhiteSpace(baseAddress)) { httpState.BaseAddress = new Uri(baseAddress); } if (!string.IsNullOrWhiteSpace(path)) { httpState.BaseAddress = new Uri(baseAddress); if (path != null) { string[] pathParts = path.Split('/'); foreach (string pathPart in pathParts) { httpState.PathSections.Push(pathPart); } } } return(httpState); }
protected static HttpState GetHttpState(out MockedFileSystem fileSystem, out IPreferences preferences, string baseAddress = "", string header = "", string path = "", IDictionary <string, string> urlsWithResponse = null, bool readFromFile = false, string fileContents = "", string contentType = "") { fileSystem = new MockedFileSystem(); preferences = new NullPreferences(); return(GetHttpStateWithOptional(ref fileSystem, ref preferences, baseAddress, header, path, urlsWithResponse, readFromFile, fileContents, contentType)); }