Example #1
0
        /// <summary>
        /// Construct exception message since CloudException.Message doesn't contain details (sometimes)
        /// </summary>
        protected virtual string WrapCloudExceptionMessage(CloudException exception)
        {
            if (exception.Response?.Content?.IsNullOrEmpty() == false)
            {
                var unescapedContent = Regex.Unescape(exception?.Response?.Content);
                return($"StatusCode: {exception?.Response?.StatusCode}; Content:{unescapedContent}");
            }

            return(exception.ToString());
        }
        public void LogsError()
        {
            Log4NetTracingInterceptor logger = new Log4NetTracingInterceptor("app.config");
            string         invocationId      = "12345";
            CloudException exception         = new CloudException("I'm a cloud exception!");
            string         expected          = string.Format("ERROR - invocationId: {0}\r\n{1}\r\n", invocationId, exception.ToString());

            logger.Error(invocationId, exception);
            string actual = File.ReadAllText(logFileName);

            Assert.Equal(expected, actual);
        }
        public void LogsError()
        {
            Log4NetTracingInterceptor logger = new Log4NetTracingInterceptor("app.config");
            string invocationId = "12345";
            CloudException exception = new CloudException("I'm a cloud exception!");
            string expected = string.Format("ERROR - invocationId: {0}\r\n{1}\r\n", invocationId, exception.ToString());

            logger.Error(invocationId, exception);
            string actual = File.ReadAllText(logFileName);

            Assert.Equal(expected, actual);
        }