private static IEnumerable <CompositeRootCommandResponse> GetCommandResponses(WebRequest request, IEnumerable <CompositeRootCommandRequest> commands)
        {
            using (var requestContentStream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(commands))))
            {
                var returnedBytes = CompositeRootHttpServerTesterConnection.SendRequest(request, "application/json", requestContentStream, out string responseContentType, out string responseContentEncoding);

                try
                {
                    return(JsonConvert.DeserializeObject <CompositeRootCommandResponse[]>(Encoding.UTF8.GetString(returnedBytes)) as IEnumerable <CompositeRootCommandResponse>);
                }
                catch
                {
                    return(new CompositeRootCommandResponse[]
                    {
                        new CompositeRootCommandResponse
                        {
                            Success = true,
                            ReturnValue = returnedBytes,
                            ReturnValueContentType = responseContentType,
                            ReturnValueContentEncoding = responseContentEncoding
                        }
                    });
                }
            }
        }
        private CompositeRootHttpServerTesterConnection CreateCompositeRootHttpServerTesterConnection(CompositeRootConfiguration configuration, WebRequest request)
        {
            var response = JsonConvert.DeserializeObject <CompositeRootAuthenticatorResponse>(Encoding.UTF8.GetString(CompositeRootHttpServerTesterConnection.SendRequest(request, out _, out _)));

            var sessionToken = response.SessionToken;
            CompositeRootHttpServerTesterConnection compositeRootHttpServerTesterConnection = null;

            try
            {
                compositeRootHttpServerTesterConnection = new CompositeRootHttpServerTesterConnection(configuration.Endpoint, sessionToken);
                if (!_connections.TryAdd(sessionToken, compositeRootHttpServerTesterConnection))
                {
                    return(null);
                }
            }
            catch
            {
                compositeRootHttpServerTesterConnection?.Dispose();
                throw;
            }

            return(compositeRootHttpServerTesterConnection);
        }