Ejemplo n.º 1
0
        public void CanCreateWithResultAndExpectedStatusCodeTest()
        {
            var outcomes = new List <HttpOutcome>
            {
                new HttpOutcome(
                    new Uri("http://www.google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.Redirect,
                    "Redirect to HTTPS",
                    TimeSpan.FromMilliseconds(50)),
                new HttpOutcome(
                    new Uri("https://google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.OK,
                    "OK",
                    TimeSpan.FromMilliseconds(234))
            };
            var result = new HttpResult(outcomes);

            var target = new HttpOutcomeException(result, HttpStatusCode.Forbidden);

            Trace.WriteLine(target.Message);

            target.Message.Should().Contain("http://www.google.com");
            target.Message.Should().Contain("https://google.com");
        }
Ejemplo n.º 2
0
        public void MessageReturnsValueWhenCreatedWithMessageTest()
        {
            var exceptionMessage = Guid.NewGuid().ToString();

            var target = new HttpOutcomeException(exceptionMessage);

            target.Message.Should().Be(exceptionMessage);
        }
        public void CanBeCreatedWithMessageAndExceptionTest()
        {
            var exceptionMessage = Guid.NewGuid().ToString();
            var innerExceptionMessage = Guid.NewGuid().ToString();

            var innerException = new TypeLoadException(innerExceptionMessage);
            var target = new HttpOutcomeException(exceptionMessage, innerException);

            target.Message.Should().Be(exceptionMessage);
            target.InnerException.Should().Be(innerException);
        }
Ejemplo n.º 4
0
        public void CanBeCreatedWithMessageAndExceptionTest()
        {
            var exceptionMessage      = Guid.NewGuid().ToString();
            var innerExceptionMessage = Guid.NewGuid().ToString();

            var innerException = new TypeLoadException(innerExceptionMessage);
            var target         = new HttpOutcomeException(exceptionMessage, innerException);

            target.Message.Should().Be(exceptionMessage);
            target.InnerException.Should().Be(innerException);
        }
        public void CanBeSerializedAndDeserializedTest()
        {
            var exceptionMessage = Guid.NewGuid().ToString();
            var innerExceptionMessage = Guid.NewGuid().ToString();
            var innerException = new TypeLoadException(innerExceptionMessage);
            var target = new HttpOutcomeException(exceptionMessage, innerException);

            using (var ms = new MemoryStream())
            {
                var formatter = new BinaryFormatter();

                formatter.Serialize(ms, target);
                ms.Seek(0, SeekOrigin.Begin);

                var outputException = formatter.Deserialize(ms) as HttpOutcomeException;

                outputException.Should().NotBeNull();
                target.Message.Should().Be(exceptionMessage);
                target.InnerException.Should().Be(innerException);
            }
        }
Ejemplo n.º 6
0
        public void CanBeSerializedAndDeserializedTest()
        {
            var exceptionMessage      = Guid.NewGuid().ToString();
            var innerExceptionMessage = Guid.NewGuid().ToString();
            var innerException        = new TypeLoadException(innerExceptionMessage);
            var target = new HttpOutcomeException(exceptionMessage, innerException);

            using (var ms = new MemoryStream())
            {
                var formatter = new BinaryFormatter();

                formatter.Serialize(ms, target);
                ms.Seek(0, SeekOrigin.Begin);

                var outputException = formatter.Deserialize(ms) as HttpOutcomeException;

                outputException.Should().NotBeNull();
                target.Message.Should().Be(exceptionMessage);
                target.InnerException.Should().Be(innerException);
            }
        }
Ejemplo n.º 7
0
        public void CanSerializeAndDeserializeResultWithStatusCodeTest()
        {
            var outcomes = new List <HttpOutcome>
            {
                new HttpOutcome(
                    new Uri("http://www.google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.Redirect,
                    "Redirect to HTTPS",
                    TimeSpan.FromMilliseconds(50)),
                new HttpOutcome(
                    new Uri("https://google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.OK,
                    "OK",
                    TimeSpan.FromMilliseconds(234))
            };
            var result = new HttpResult(outcomes);

            var target = new HttpOutcomeException(result, HttpStatusCode.Forbidden);

            using (var ms = new MemoryStream())
            {
                var formatter = new BinaryFormatter();

                formatter.Serialize(ms, target);
                ms.Seek(0, SeekOrigin.Begin);

                var outputException = formatter.Deserialize(ms) as HttpOutcomeException;

                Trace.WriteLine(outputException.Message);

                outputException.Should().NotBeNull();
                target.Message.Should().Be(outputException.Message);
                target.Result.ShouldBeEquivalentTo(result);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Renders the exception.
        /// </summary>
        /// <param name="ex">The exception.</param>
        /// <returns></returns>
        private static bool RenderException(HttpOutcomeException ex)
        {
            Trace.WriteLine(ex);

            return true;
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Renders the exception.
        /// </summary>
        /// <param name="ex">The exception.</param>
        /// <returns></returns>
        private static bool RenderException(HttpOutcomeException ex)
        {
            Trace.WriteLine(ex);

            return(true);
        }
        public void CanCreateWithResultAndExceptionTest()
        {
            var outcomes = new List<HttpOutcome>
            {
                new HttpOutcome(
                    new Uri("http://www.google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.Redirect,
                    "Redirect to HTTPS",
                    TimeSpan.FromMilliseconds(50)),
                new HttpOutcome(
                    new Uri("https://google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.OK,
                    "OK",
                    TimeSpan.FromMilliseconds(234))
            };
            var result = new HttpResult(outcomes);
            var ex = new TimeoutException();

            var target = new HttpOutcomeException(result, ex);

            Trace.WriteLine(target.Message);

            target.Message.Should().Contain("http://www.google.com");
            target.Message.Should().Contain("https://google.com");
            target.Message.Should().Contain(ex.Message);
        }
        public void MessageReturnsValueWhenCreatedWithMessageTest()
        {
            var exceptionMessage = Guid.NewGuid().ToString();

            var target = new HttpOutcomeException(exceptionMessage);

            target.Message.Should().Be(exceptionMessage);
        }
        public void MessageReturnsValueWhenCreatedWithDefaultConstructorTest()
        {
            var target = new HttpOutcomeException();

            target.Message.Should().NotBeEmpty();
        }
        public void CanSerializeAndDeserializeResultWithStatusCodeTest()
        {
            var outcomes = new List<HttpOutcome>
            {
                new HttpOutcome(
                    new Uri("http://www.google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.Redirect,
                    "Redirect to HTTPS",
                    TimeSpan.FromMilliseconds(50)),
                new HttpOutcome(
                    new Uri("https://google.com"),
                    HttpMethod.Get,
                    HttpStatusCode.OK,
                    "OK",
                    TimeSpan.FromMilliseconds(234))
            };
            var result = new HttpResult(outcomes);

            var target = new HttpOutcomeException(result, HttpStatusCode.Forbidden);

            using (var ms = new MemoryStream())
            {
                var formatter = new BinaryFormatter();

                formatter.Serialize(ms, target);
                ms.Seek(0, SeekOrigin.Begin);

                var outputException = formatter.Deserialize(ms) as HttpOutcomeException;

                Trace.WriteLine(outputException.Message);

                outputException.Should().NotBeNull();
                target.Message.Should().Be(outputException.Message);
                target.Result.ShouldBeEquivalentTo(result);
            }
        }
Ejemplo n.º 14
0
        public void MessageReturnsValueWhenCreatedWithDefaultConstructorTest()
        {
            var target = new HttpOutcomeException();

            target.Message.Should().NotBeEmpty();
        }