From bb1631302419431b974e7dcb14e8fe29c10c1efc Mon Sep 17 00:00:00 2001 From: Alekhya Reddy Date: Tue, 7 Apr 2020 18:40:13 -0700 Subject: [PATCH] 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 --- .../Wox.Test/Plugins/WindowsIndexerTest.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs b/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs index 9df2aa5892..fae98e9ab8 100644 --- a/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs +++ b/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs @@ -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); } } }