Exemplo n.º 1
0
        private async void TestRestClientFactory(Action <HttpRequestMessage, CancellationToken> assertion)
        {
            var restClientFactory = new TestRestClientFactory(productInfo, assertion);

            using var restClient = restClientFactory.Create(_serviceEndpoint);
            await restClient.HealthApi.GetHealthStatusWithHttpMessagesAsync();
        }
        public void GetCustomiazeClient_BaseUriRightFact()
        {
            var restClientFactory = new TestRestClientFactory(productInfo, null);

            using var restClient = restClientFactory.Create(_serviceEndpoint);
            Assert.Equal(Endpoint, restClient.BaseUri.AbsoluteUri);
        }
Exemplo n.º 3
0
        public async void IsServiceHealthyReturnTrue()
        {
            using var signalRServiceRestClient = new TestRestClientFactory(UserAgent, HttpStatusCode.OK).Create(serviceEndpoint);
            var healthApi = new HealthApi(signalRServiceRestClient);

            var operationResponse = await healthApi.GetHealthStatusWithHttpMessagesAsync();

            Assert.Equal(HttpStatusCode.OK, operationResponse.Response.StatusCode);
        }
Exemplo n.º 4
0
 internal async Task IsServiceHealthy_ReturnTrue_Test()
 {
     var context = new ServiceManagerContext
     {
         ServiceEndpoints = new ServiceEndpoint[] { new ServiceEndpoint(_testConnectionString) }
     };
     var factory        = new TestRestClientFactory(UserAgent, HttpStatusCode.OK);
     var serviceManager = new ServiceManager(context, factory);
     var actual         = await serviceManager.IsServiceHealthy(default);
Exemplo n.º 5
0
        [InlineData(HttpStatusCode.Conflict)]           //won't retry
        public async void IsServiceHealthyThrowException(HttpStatusCode statusCode)
        //always throw exception when status code != 200
        {
            string contentString = "response content";

            using var signalRServiceRestClient = new TestRestClientFactory(UserAgent, statusCode, contentString).Create(serviceEndpoint);
            var healthApi = new HealthApi(signalRServiceRestClient);

            HttpOperationException exception = await Assert.ThrowsAsync <HttpOperationException>(() => healthApi.GetHealthStatusWithHttpMessagesAsync());

            Assert.Equal(statusCode, exception.Response.StatusCode);
            Assert.Equal(contentString, exception.Response.Content);
        }