public void WhenISendARequest()
        {
            var httpMessageHelper = new HttpMessageHelper();

            var request         = this.scenarioContext.GetValueOrDefault <HttpRequestMessage>(ContextKey.Request);
            var responseMessage = httpMessageHelper.GetResponseMessage(request, scenarioContext);

            scenarioContext[ContextKey.ResponseMessage] = responseMessage;
            scenarioContext[ContextKey.StatusCode]      = responseMessage.StatusCode;

            if (!responseMessage.IsSuccessStatusCode)
            {
                var result = (string)scenarioContext[ContextKey.Result];

                Assert.IsFalse(string.IsNullOrWhiteSpace(result), $"Expected response to have a result. {request.RequestUri.PathAndQuery}");

                var errorMessageContent = JsonConvert.DeserializeObject <ErrorMessage>(result);
                var jsonErrorMessage    = JsonConvert.DeserializeObject <ErrorResponseBody>(result);

                if ((int)responseMessage.StatusCode <= 500)
                {
                    scenarioContext[ContextKey.ErrorMessage] = jsonErrorMessage.Detail;
                }
                else
                {
                    scenarioContext[ContextKey.ErrorMessage] = errorMessageContent.Message;
                }
            }
        }
        public void WhenICallTheInsolvenciesService(string searchDate)
        {
            var url = scenarioContext.GetMandatoryValue <string>(ContextKey.Url);
            var httpMessageHelper = new HttpMessageHelper();
            var requestMessage    = httpMessageHelper.CreateRequestMessage(url, "GET");
            var headers           = scenarioContext.GetValueOrDefault <Dictionary <string, string> >(ContextKey.Headers);

            foreach (var item in headers)
            {
                requestMessage.Headers.Add(item.Key, item.Value);
            }

            if (searchDate == null)
            {
                searchDate = "current";
            }

            switch (searchDate)
            {
            case OperationDateTypes.Current:
                break;

            case OperationDateTypes.CurrentMinus0Days:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus1Day:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus1Year:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus2Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-2).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus3Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-3).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus4Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-4).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus5Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-5).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus6Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-6).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus7Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-7).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus8Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-8).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentMinus9Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(-9).ToString("yyyy-MM-dd"));
                break;

            case OperationDateTypes.CurrentPlus6Years:
                requestMessage.Headers.Add("Operation-Date", DateTime.Now.AddYears(6).ToString("yyyy-MM-dd"));
                break;

            default:
                throw new ArgumentException($"search Date Type {searchDate} is not in a list of Operation Date Types");
            }

            scenarioContext[ContextKey.Request] = requestMessage;

            var request         = scenarioContext.GetValueOrDefault <HttpRequestMessage>(ContextKey.Request);
            var responseMessage = httpMessageHelper.GetResponseMessage(request, scenarioContext);

            scenarioContext[ContextKey.ResponseMessage] = responseMessage;
            scenarioContext[ContextKey.StatusCode]      = responseMessage.StatusCode;

            if (responseMessage.IsSuccessStatusCode)
            {
                return;
            }

            var result = (string)this.scenarioContext[ContextKey.Result];

            Assert.IsFalse(string.IsNullOrWhiteSpace(result), $"Expected response to have a result. {request.RequestUri.PathAndQuery}");
        }