diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs index 5de88521..ee7d7852 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/ResultSet.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Data.Common; -namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts +namespace Microsoft.SqlTools.ServiceLayer.QueryExecution { public class ResultSet { diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/DisposeTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/DisposeTests.cs new file mode 100644 index 00000000..def3c6b6 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/DisposeTests.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution +{ + public class DisposeTests + { + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/ExecuteTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/ExecuteTests.cs new file mode 100644 index 00000000..4e2ccab1 --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/ExecuteTests.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.SqlServer.Management.SqlParser.MetadataProvider; +using Microsoft.SqlTools.ServiceLayer.Connection; +using Microsoft.SqlTools.ServiceLayer.Connection.Contracts; +using Microsoft.SqlTools.ServiceLayer.QueryExecution; +using Microsoft.SqlTools.Test.Utility; +using Moq; +using Xunit; + +namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution +{ + public class ExecuteTests + { + [Fact] + public void QueryCreationTest() + { + // If I create a new query... + Query query = new Query("NO OP", CreateTestConnectionInfo()); + + // Then: + // ... It should not have executed + Assert.False(query.HasExecuted, "The query should not have executed."); + + // ... The results should be empty + Assert.Empty(query.ResultSets); + Assert.Empty(query.ResultSummary); + } + + private static ConnectionInfo CreateTestConnectionInfo() + { + // Create connection info + ConnectionDetails connDetails = new ConnectionDetails + { + UserName = "sa", + Password = "Yukon900", + DatabaseName = "AdventureWorks2016CTP3_2", + ServerName = "sqltools11" + }; + +#if !USE_LIVE_CONNECTION + // Use the mock db connection factory + ISqlConnectionFactory factory = new TestSqlConnectionFactory(); +#else + // Use a real db connection factory + ISqlConnectionFactory factory = new SqlConnectionFactory(); +#endif + + return new ConnectionInfo(factory, "test://test", connDetails); + } + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SubsetTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SubsetTests.cs new file mode 100644 index 00000000..f64dd96c --- /dev/null +++ b/test/Microsoft.SqlTools.ServiceLayer.Test/QueryExecution/SubsetTests.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution +{ + public class SubsetTests + { + } +}