mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
* 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
38 lines
1.4 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|