public async Task ShouldLogErrors_SwitchedOn_LogErrors()
        {
            //// Arrange
            var apiErrorSettings = new ApiErrorSettings
            {
                Logging = new LoggingSettings
                {
                    ShouldLogErrors = true
                }
            };

            CreateClient(apiErrorSettings);

            //// Act
            var response = await _ApiClient.GetAsync($"{_BasePath}/random");

            //// Assert
            Assert.AreEqual(HttpStatusCode.InternalServerError, response.StatusCode);
        }
        public async Task UseCamelCase_SwitchedOff_ResponseInTitleCase()
        {
            //// Arrange
            var apiErrorSettings = new ApiErrorSettings
            {
                Serialization = new SerializationSettings
                {
                    UseCamelCase = false
                }
            };

            CreateClient(apiErrorSettings);

            //// Act
            var response = await _ApiClient.GetAsync($"{_BasePath}/random");

            //// Assert
            var responseContent = await response.Content.ReadAsStringAsync();

            Assert.IsFalse(responseContent.Contains("\"statusCode\":"));
            Assert.IsTrue(responseContent.Contains("\"StatusCode\":"));
        }
Exemplo n.º 3
0
        public async Task IncludeExceptionDetail_SwitchedOn_NoExceptionInResponse()
        {
            //// Arrange
            var apiErrorSettings = new ApiErrorSettings
            {
                Message = new MessageSettings
                {
                    IncludeExceptionDetail = true
                }
            };

            CreateClient(apiErrorSettings);

            //// Act
            var response = await _ApiClient.GetAsync($"{_BasePath}/random");

            //// Assert
            var responseContent = await response.Content.ReadAsStringAsync();

            var responseData = JsonConvert.DeserializeObject <ErrorDetail>(responseContent);

            Assert.IsNotNull(responseData.Exception);
            Assert.AreEqual("Random exception", responseData.Exception.Message);
        }