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"); }
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); }
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); } }
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); } }
/// <summary> /// Renders the exception. /// </summary> /// <param name="ex">The exception.</param> /// <returns></returns> private static bool RenderException(HttpOutcomeException ex) { Trace.WriteLine(ex); return true; }
/// <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 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); } }