private async Task UpdateService(string serviceId) { var service = new Service { Id = _serviceId, ServiceType = _serviceType, Address = _serviceAddress, HealthCheck = new HealthCheck { HealthCheckType = _healthCheckType, Address = _healthEndpoint, Interval = _healthInterval, DeregisterCriticalServiceAfter = _deregisterCriticalServiceAfter } }; var jsonString = JsonConvert.SerializeObject(service); var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); var httpClient = ApiTestServer.GetHttpClient(); _response = await httpClient.PutAsync($"/api/services/{serviceId}", httpContent); _responseContent = await _response.Content.ReadAsStringAsync(); var response = await httpClient.GetAsync($"/api/services/{serviceId}"); if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsStringAsync(); _responseObject = JObject.Parse(responseContent); } }
private async Task ThenServiceNotExists(string serviceId) { var httpClient = ApiTestServer.GetHttpClient(); var response = await httpClient.GetAsync($"/api/services/{serviceId}"); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); }
private async Task WhenListOfServicesIsDownloaded() { var httpClient = ApiTestServer.GetHttpClient(); _response = await httpClient.GetAsync($"/api/services"); _responseContent = await _response.Content.ReadAsStringAsync(); }
private async Task ThenServiceWasRegistered(string serviceId) { var httpClient = ApiTestServer.GetHttpClient(); var serviceResponse = await httpClient.GetStringAsync($"/api/services/{serviceId}"); var service = JsonConvert.DeserializeObject <Service>(serviceResponse); Assert.NotNull(service); }
private async Task ThenServiceHealthIs(string healthStatus) { Thread.Sleep(2000); var httpClient = ApiTestServer.GetHttpClient(); var httpResponseMessage = await httpClient.GetAsync($"/api/services/{_serviceId}/health/current"); var response = await httpResponseMessage.Content.ReadAsStringAsync(); dynamic parsedResponse = JObject.Parse(response); Assert.Equal(healthStatus, (string)parsedResponse.healthState); }
private async Task WhenGetServiceWithId(string serviceId) { var httpClient = ApiTestServer.GetHttpClient(); _response = await httpClient.GetAsync($"/api/services/{serviceId}"); _responseContent = await _response.Content.ReadAsStringAsync(); if (_response.IsSuccessStatusCode) { _serviceObject = JObject.Parse(_responseContent); } }
private async Task RegisterService() { var service = new Service { Id = _serviceId, ServiceType = _serviceType, Address = _serviceAddress, HealthCheck = new HealthCheck { HealthCheckType = _healthCheckType } }; var jsonString = JsonConvert.SerializeObject(service); var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); var httpClient = ApiTestServer.GetHttpClient(); _response = await httpClient.PostAsync("/api/services", httpContent); }
private async Task WhenServiceIsDeleting(string serviceId) { var httpClient = ApiTestServer.GetHttpClient(); _response = await httpClient.DeleteAsync($"/api/services/{serviceId}"); }