public void CanSerializeAndDeserializeResultWithLocationTest()
{
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, new Uri("https://www.google.com"));
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);
}
}