public static async Task <bool> SeleneIsReachableAsync(string seleneUrl) { using (var client = new SeleneApiClient(seleneUrl)) { HttpResponseMessage response = await client.PostAsJsonAsync(SeleneApiEndpoints.Handshake, new { Hello = "ThisIsTheTestRunner" }); return(response.IsSuccessStatusCode); } }
static async Task ReportToSeleneAsync(TestMethodInstance instance, ITestResult result, string apiPath, TimeSpan timeTaken, Configuration config, bool reportException) { using (var client = new SeleneApiClient(config.SeleneApiUrl)) { var browserObj = instance.GetMetadata("browser"); var browser = browserObj != null?browserObj.ToString() : string.Empty; TestInfo test = new TestInfo { Assembly = instance.GetMethod().Module.Assembly.GetName().Name, AssemblyRunId = config.AssemblyRunId, AutomatedRunId = config.AutomatedRunId, Team = config.Team, Test = instance.GetMethod().Name, Timestamp = DateTime.Now, TimeTaken = timeTaken != null ? timeTaken : TimeSpan.FromMilliseconds(0), Notification = apiPath.Split('/')[1], Id = instance.TestId, Browser = browser == "chrome" ? "Chrome" : browser == "internet explorer" ? "IE" : string.Empty }; if (reportException && result.Exception != null) { test.ExceptionName = result.Exception.GetType().Name; test.ExceptionMessage = result.Exception.Message; test.ExceptionSource = result.Exception.Source; } else { test.ExceptionName = test.ExceptionMessage = test.ExceptionSource = string.Empty; } HttpResponseMessage response = await client.PostAsJsonAsync(apiPath, test); SeSugar.Environment.Logger.LogLine("Call to Selene {0} responded with {1} ({2}).", apiPath, response.StatusCode, (int)response.StatusCode); } }