Пример #1
0
        public void CheckApiException()
        {
            Exception ex  = new ApiException("Message", new Exception("Inner exception."));
            Exception ex2 = new ApiException("Message");

            string exceptionToString = ex.ToString();

            Assert.AreEqual(exceptionToString, ex.ToString());
            Assert.AreEqual(exceptionToString, ex2.ToString());
        }
Пример #2
0
            public void DoesNotThrowIfBodyIsNotDefined()
            {
                var response = CreateResponse(HttpStatusCode.GatewayTimeout);

                var exception            = new ApiException(response);
                var stringRepresentation = exception.ToString();

                Assert.NotNull(stringRepresentation);
            }
Пример #3
0
            public void DoesNotPrintNonStringContent()
            {
                var responseBody = new byte[0];
                var response     = CreateResponse(
                    HttpStatusCode.GatewayTimeout,
                    responseBody);

                var exception            = new ApiException(response);
                var stringRepresentation = exception.ToString();

                Assert.NotNull(stringRepresentation);
            }
Пример #4
0
            public void DoesNotThrowIfBodyIsNotDefined()
            {
                var response = new Response(
                    HttpStatusCode.GatewayTimeout,
                    null,
                    new Dictionary <string, string>(),
                    "application/json");

                var exception            = new ApiException(response);
                var stringRepresentation = exception.ToString();

                Assert.NotNull(stringRepresentation);
            }
Пример #5
0
            public void ContainsResponseBody()
            {
                const string responseBody = @"{""errors"":[{""code"":""custom"",""field"":""key"",""message"":""key is " +
                                            @"already in use"",""resource"":""PublicKey""}],""message"":""Validation Failed""}";
                var response = CreateResponse(
                    HttpStatusCode.GatewayTimeout,
                    responseBody);

                var exception            = new ApiException(response);
                var stringRepresentation = exception.ToString();

                Assert.Contains(responseBody, stringRepresentation);
            }
Пример #6
0
            public void DoesNotPrintNonStringContent()
            {
                var responceBody = new byte[0];
                var response     = new Response(
                    HttpStatusCode.GatewayTimeout,
                    responceBody,
                    new Dictionary <string, string>(),
                    "application/json");

                var exception            = new ApiException(response);
                var stringRepresentation = exception.ToString();

                Assert.NotNull(stringRepresentation);
            }
Пример #7
0
 public virtual bool Equals(ApiException exc)
 {
     return(exc != null && ToString().Equals(exc.ToString(), System.StringComparison.Ordinal));
 }
Пример #8
0
            public void DoesNotPrintNonStringContent()
            {
                var responceBody = new byte[0];
                var response = new Response(
                    HttpStatusCode.GatewayTimeout,
                    responceBody,
                    new Dictionary<string, string>(),
                    "application/json"
                );

                var exception = new ApiException(response);
                var stringRepresentation = exception.ToString();
                Assert.NotNull(stringRepresentation);
            }
Пример #9
0
            public void DoesNotThrowIfBodyIsNotDefined()
            {
                var response = new Response(
                    HttpStatusCode.GatewayTimeout,
                    null,
                    new Dictionary<string, string>(),
                    "application/json"
                );

                var exception = new ApiException(response);
                var stringRepresentation = exception.ToString();
                Assert.NotNull(stringRepresentation);
            }
Пример #10
0
            public void ContainsResponseBody()
            {
                const string responseBody = @"{""errors"":[{""code"":""custom"",""field"":""key"",""message"":""key is " +
                                            @"already in use"",""resource"":""PublicKey""}],""message"":""Validation Failed""}";
                var response = new Response(
                    HttpStatusCode.GatewayTimeout,
                    responseBody,
                    new Dictionary<string, string>(),
                    "application/json"
                    );

                var exception = new ApiException(response);
                var stringRepresentation = exception.ToString();
                Assert.Contains(responseBody, stringRepresentation);
            }