Modified the test, the connection need not be null after being disposed. There is no direct way of checking if an object has been disposed other than to throw the InvalidOperationException

This commit is contained in:
Alekhya Reddy 2020-04-07 18:40:13 -07:00
parent a5ce2a5a62
commit bb16313024

View File

@ -132,14 +132,33 @@ namespace Wox.Test.Plugins
_api.InitQueryHelper(out queryHelper, 10);
_api.ModifyQueryHelper(ref queryHelper, "*");
string keyword = "test";
bool commandDisposed = false;
bool resultDisposed = false;
// Act
_api.ExecuteQuery(queryHelper, keyword);
try
{
_api.command.ExecuteReader();
}
catch(InvalidOperationException)
{
commandDisposed = true;
}
try
{
_api.WDSResults.Read();
}
catch(InvalidOperationException)
{
resultDisposed = true;
}
// Assert
Assert.IsNull(_api.conn);
Assert.IsNull(_api.command);
Assert.IsNull(_api.WDSResults);
Assert.IsTrue(_api.conn.State == System.Data.ConnectionState.Closed);
Assert.IsTrue(commandDisposed);
Assert.IsTrue(resultDisposed);
}
}
}