Test 'M:MyTests.WebFilter.MonitorTests.can_start_monitor' failed: Error while unloading appdomain. (Exception from HRESULT: 0x80131015)
System.CannotUnloadAppDomainException: Error while unloading appdomain. (Exception from HRESULT: 0x80131015)
at System.AppDomain.Unload(AppDomain domain)
at Xunit.ExecutorWrapper.Dispose()
at Xunit.Runner.TdNet.TdNetRunner.TestDriven.Framework.ITestRunner.RunMember(ITestListener listener, Assembly assembly, MemberInfo member)
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()
Failing Test:
[Fact]
public void can_start_monitor()
{
MonitorService mon = new MonitorService();
mon.Start();
var client = new ApiClient(ApiTests.BASE_URL);
client.Ping(); //performs a HTTP GET call
System.Threading.Thread.Sleep(3000);
mon.Stop();
}
[Fact]
public void can_start_monitor()
{
MonitorService mon = new MonitorService();
mon.Start();
var client = new ApiClient(ApiTests.BASE_URL);
//client.Ping();
System.Threading.Thread.Sleep(3000);
mon.Stop();
}
Unloading an AppDomain with an outstanding network request seems likely to fail. It may help to call Abort() on any outstanding requests (or even allow some lengthy timeout after calling Stop()), but generally speaking I wouldn't expect an AppDomain hosting a proxy to cleanly unload.