Adding support for database literal references for Dacpac and SqlProj references (#1858)

* fixing up some nullable spots

* Adding database literal support

* Adding tests and support for same database refs

* Fixing test

* merge laggard

* Split database reference tests up

* PR feedback

* Normalizing strings for cross-plat test passing

* Updating Projects nuget package

* Fixing up test
This commit is contained in:
Benjin Dubishar
2023-02-10 11:36:31 -08:00
committed by GitHub
parent 15250a9178
commit d0d67373d1
21 changed files with 293 additions and 99 deletions

View File

@@ -0,0 +1,37 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.SqlProjects
{
public class SqlProjectTests
{
[Test]
public void DatabaseReferenceValidationTest()
{
// Verify that Validate() throws when both DatabaseLiteral and DatabaseVariable are set
AddUserDatabaseReferenceParams reference = new AddDacpacReferenceParams() // any concrete class will do
{
DatabaseLiteral = "DatabaseName",
DatabaseVariable = "$(DatabaseVariable)"
};
Assert.Throws<ArgumentException>(() => reference.Validate(), $"Validate() for a reference with both {nameof(reference.DatabaseLiteral)} and {nameof(reference.DatabaseVariable)} should have failed");
// Verify that Validate() passes any other time
reference = new AddDacpacReferenceParams() { DatabaseLiteral = "DatabaseName" };
reference.Validate();
reference = new AddDacpacReferenceParams() { DatabaseVariable = "$(DatabaseVariable)" };
reference.Validate();
reference = new AddDacpacReferenceParams();
reference.Validate();
}
}
}