/// <summary> /// Creates a web site configuration. /// </summary> /// <param name="website">The website configuration to create.</param> /// <returns>The created configuration.</returns> public WebsiteTestConfiguration CreateWebSite(WebsiteTestConfiguration website) { WebRequest request = WebRequest.Create(String.Format(ConnectionUrl.WebSitesUrl, this.apiKey)); request.Method = "POST"; request.ContentType = "application/xml"; using (Stream requestStream = request.GetRequestStream()) { XmlSerializer xmlSerializer = new XmlSerializer(typeof (WebsiteTestConfiguration)); xmlSerializer.Serialize(requestStream, website); } WebResponse response = request.GetResponse(); using (Stream responseStream = response.GetResponseStream()) { XmlSerializer xmlSerializer = new XmlSerializer(typeof (WebsiteTestConfiguration)); WebsiteTestConfiguration result = (WebsiteTestConfiguration) xmlSerializer.Deserialize(responseStream); return result; } }
/// <summary> /// Creates a new site and runs a test. /// </summary> /// <param name="configuration">The configuration for the new site.</param> public TestRun CreateSiteAndRunTest(WebsiteTestConfiguration configuration) { WebsiteTestConfiguration site = this.connector.CreateWebSite(configuration); return this.connector.CreateTestRun(site.Id, CreateTestRunConfiguration()); }
/// <summary> /// Creates a new site and runs a test while polling the results. /// </summary> /// <param name="configuration">The configuration for the new site.</param> /// <param name="targetDirectory">The target directory to poll into.</param> public TestRun CreateSiteAndRunTestAndPollResult(WebsiteTestConfiguration configuration, string targetDirectory) { WebsiteTestConfiguration site = this.connector.CreateWebSite(configuration); return RunTestOnSiteInternal(site, true, targetDirectory); }
private TestRun RunTestOnSiteInternal(WebsiteTestConfiguration site, bool poll, string targetDirectory) { TestRun testRun = this.connector.CreateTestRun(site.Id, CreateTestRunConfiguration()); if (poll) { TestRunResultPoller poller = new TestRunResultPoller(this.apiKey); testRun = poller.PollResultToDirectory(site.Id, testRun.Id, targetDirectory); } return testRun; }