mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Upgrade SMO to 150 preview (#701)
* Switch to the unified SMO NuGet so all binaries are strong named and signed. * use one AssemblyLoader instance for all loads * Revert "use one AssemblyLoader instance for all loads" This reverts commit 48c59ffd5c57152de281c87acdbcad7ddf7ab760. * Stop creating multiple AssemblyLoadContext objects during composition, per https://github.com/dotnet/coreclr/issues/19632 * restore high entropyva property * Improve the comment * Update SMO to 150 and fix scripting for objects with a single quote in their name. * restore newtonsoft reference
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
|
||||
using NUnit.Framework;
|
||||
using Assert = NUnit.Framework.Assert;
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Scripting
|
||||
{
|
||||
|
||||
public class ScriptingExtensionMethodsTests
|
||||
{
|
||||
/// <summary>
|
||||
/// SQL sysname supports single quotes in object names, so URN attributes need to be properly escaped
|
||||
/// </summary>
|
||||
[Xunit.Fact]
|
||||
public void ToUrnEscapesAttributes()
|
||||
{
|
||||
var scriptingObject = new ScriptingObject() { Name = "quoted'Name", Schema = "quoted'Schema", Type = "Table" };
|
||||
var urn = scriptingObject.ToUrn("server", "quoted'db");
|
||||
Assert.That(urn.ToString, Is.EqualTo("Server[@Name='SERVER']/Database[@Name='quoted''db']/Table[@Name='quoted''Name' and @Schema = 'quoted''Schema']"), "Urn should have escaped Name attributes");
|
||||
Assert.That(urn.Type, Is.EqualTo("Table"), "Urn Type");
|
||||
// These assertions are more for educational purposes than for testing, since the methods are Urn methods in SFC.
|
||||
Assert.That(urn.GetNameForType("Database"), Is.EqualTo("quoted'db"), "GetNameForType('Database')");
|
||||
Assert.That(urn.GetAttribute("Schema"), Is.EqualTo("quoted'Schema"), "GetAttribute('Schema')");
|
||||
}
|
||||
|
||||
[Xunit.Fact]
|
||||
public void ToObjectStringUnescapesAttributes()
|
||||
{
|
||||
var urn = new Urn(@"Server[@Name = 'SERVER']/Database[@Name = 'quoted''db']/Table[@Name = 'quoted''Name' and @Schema = 'quoted''Schema']");
|
||||
var scriptingObject = urn.ToScriptingObject();
|
||||
Assert.That(scriptingObject.Type, Is.EqualTo("Table"), "Type");
|
||||
Assert.That(scriptingObject.Name, Is.EqualTo("quoted'Name"), "Name");
|
||||
Assert.That(scriptingObject.Schema, Is.EqualTo("quoted'Schema"), "Schema");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user