public void RunQueryTest_GetJsonFromSqlTest_SQLServerOnline() { // arrange List <string> languages = new List <string>(new string[] { "Java", "C", "Python", "C++", "C#" }); string jsonResult = string.Empty; GitHubApiQuery gitHubApiQuery = null; // act try { gitHubApiQuery = new GitHubApiQuery(languages); gitHubApiQuery.MillisecondsToWait = 100000; // Adjust for LAN service access. gitHubApiQuery.ApiItemsPerPage = 5; gitHubApiQuery.ApiPages = 1; gitHubApiQuery.RunQuery(); jsonResult = gitHubApiQuery.GetJsonFromSql(); } catch (Exception ex) { Assert.Fail(ex.Message, ex); } // assert Assert.IsFalse(string.IsNullOrEmpty(jsonResult)); }
public void RunQueryTest_GetJsonFromSqlTest_SQLServerOffline() { // arrange string jsonResult = string.Empty; GitHubApiQuery gitHubApiQuery = null; // act try { gitHubApiQuery = new GitHubApiQuery(new List <string>(new string[] { "Java" })); gitHubApiQuery.MillisecondsToWait = 10000; // Adjust for LAN service access. gitHubApiQuery.ApiItemsPerPage = 5; gitHubApiQuery.ApiPages = 1; gitHubApiQuery.RunQuery(); jsonResult = gitHubApiQuery.GetJsonFromSql(); Assert.IsTrue(string.IsNullOrEmpty(jsonResult), "\n\nPara este teste passar o SQL Server deve estar indisponível.\n"); } catch (Exception ex) { Assert.Fail(ex.Message, ex); } // assert Assert.IsTrue(string.IsNullOrEmpty(jsonResult)); }
public HttpResponseMessage GitHubQuery() { // arrange string jsonResult = string.Empty; GitHubApiQuery gitHubApiQuery = null; //Requester info - Just to log - Later a cache control may be implemented. //var ip = HttpRequestMessageExtensions.GetClientIpAddress(this.Request); // act try { gitHubApiQuery = new GitHubApiQuery(new List <string>(new string[] { "Java", "C", "Python", "C++", "C#" })); gitHubApiQuery.ApiItemsPerPage = 5; gitHubApiQuery.ApiPages = 1; gitHubApiQuery.RunQuery(); jsonResult = gitHubApiQuery.GetJsonFromSql(); } catch (FileLoadException) { // Ignore - Debug exception. } catch (Exception) { // Serviço não está ativo. //throw new Exception(ex.Message, ex); return(null); } HttpResponseMessage resp = new HttpResponseMessage { Content = new StringContent(jsonResult, System.Text.Encoding.UTF8, "application/json") }; return(resp); }