Language: C#
ServerDisconnects No Unhandeled Exception
[Test] public void Idle_ServerDisconnects_NoUnhandeledException() { bool unhandeledException = false; UnhandledExceptionEventHandler fail = (sender, args) => unhandeledException = true; try { AppDomain.CurrentDomain.UnhandledException += fail; WithLogin(client => { client.SelectInbox(); new Thread(() => { ServerException ex = Assert.Throws<ServerException>(() => client.Idle()); StringAssert.Contains("An existing connection was forcibly closed by the remote host.", ex.Message); }).Start(); new HMailServer().Stop(); }); } finally { AppDomain.CurrentDomain.UnhandledException -= fail; new HMailServer().Start(); } Assert.IsFalse(unhandeledException); }
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

