Files
sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/SqlProjects/SqlProjectTests.cs
Benjin Dubishar d0d67373d1 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
2023-02-10 11:36:31 -08:00

38 lines
1.4 KiB
C#

//
// 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();
}
}
}