mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-23 17:24:12 -05:00
Task/script refactor (#446)
* scripting working with race conditions * new service works with no race conditions * use new scripting service and commented out tests * refactored peek definition to use mssql-scripter * fixed peek definition tests * removed auto gen comment * fixed peek definition highlighting bug * made scripting async and fixed event handlers * fixed tests (without cancel and plan notifs) * removed dead code * added nuget package * CR comments + select script service implementation * minor fixes and added test * CR comments and script select * added unit tests * code review comments and cleanup
This commit is contained in:
@@ -312,9 +312,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
Scripter peekDefinition = new Scripter(null, null);
|
||||
string objectName = "tableName";
|
||||
string fullObjectName = "master.dbo.tableName";
|
||||
DefinitionResult result = peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.Table, fullObjectName, objectName, null);
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.IsErrorResult);
|
||||
Assert.Throws<NullReferenceException>(() => peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.Table, fullObjectName, objectName, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.5" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.6" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
|
||||
@@ -408,5 +408,50 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Scripting
|
||||
|
||||
Assert.Equal<int>(2, results.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScriptingObjectEquality()
|
||||
{
|
||||
ScriptingObject scriptingObject1 = new ScriptingObject { Type = "Table", Schema = "test", Name = "test_table" };
|
||||
ScriptingObject scriptingObject2 = new ScriptingObject { Type = "Table", Schema = "test", Name = "test_table" };
|
||||
ScriptingObject scriptingObject3 = null;
|
||||
Assert.Equal(scriptingObject1, scriptingObject2);
|
||||
Assert.False(scriptingObject1.Equals(scriptingObject3));
|
||||
}
|
||||
}
|
||||
|
||||
public class ScriptingUtilsTests
|
||||
{
|
||||
private static string[] TestObjects = new string[]
|
||||
{
|
||||
"Table",
|
||||
"Table]",
|
||||
"]Table",
|
||||
"Tab]le",
|
||||
"",
|
||||
"]",
|
||||
"view"
|
||||
};
|
||||
|
||||
private static string[] ExpectedObjects = new string[]
|
||||
{
|
||||
"Table",
|
||||
"Table]]",
|
||||
"]]Table",
|
||||
"Tab]]le",
|
||||
"",
|
||||
"]]",
|
||||
"view"
|
||||
};
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestQuoteObjectName()
|
||||
{
|
||||
for (int i = 0; i < TestObjects.Length; i++)
|
||||
{
|
||||
Assert.Equal(Scripter.ScriptingUtils.QuoteObjectName(TestObjects[i]), ExpectedObjects[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user