When I run the test below (NUnit and VS2008 SP1) I get the following error
Expected: ConnectFailure
But was: UnknownError
Can anyone explain what I'm doing wrong?
[Test]
public void SerializationWebExceptionTest()
{
using (var stream = new MemoryStream())
{
const WebExceptionStatus Expected = WebExceptionStatus.ConnectFailure;
var formatter = new BinaryFormatter();
var initialException = new WebException("Test", null, Expected, null);
formatter.Serialize(stream, initialException);
stream.Seek(0, SeekOrigin.Begin);
var result = (WebException)formatter.Deserialize(stream);
var actual = result.Status;
Assert.That(actual, Is.EqualTo(Expected));
}
}