mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-20 09:35:38 -05:00
Make nullable warnings a per file opt-in (#1842)
* Make nullable warnings a per file opt-in * Remove unneeded compiler directives * Remove compiler directive for User Data
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
@@ -185,32 +187,32 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
Assert.Throws<InvalidOperationException>(() => new CellUpdate(col, value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not using TestCaseSource because nUnit's test name generator
|
||||
/// doesn't like DbColumnWrapper objects as a source, due
|
||||
/// to that class lacking a ToString override.
|
||||
/// </summary>
|
||||
/// <param name="col"></param>
|
||||
/// <summary>
|
||||
/// Not using TestCaseSource because nUnit's test name generator
|
||||
/// doesn't like DbColumnWrapper objects as a source, due
|
||||
/// to that class lacking a ToString override.
|
||||
/// </summary>
|
||||
/// <param name="col"></param>
|
||||
/// <param name="obj"></param>
|
||||
[Test]
|
||||
public void RoundTripTest()
|
||||
{
|
||||
foreach (var inputs in RoundTripTestParams)
|
||||
{
|
||||
|
||||
var col = (DbColumnWrapper)inputs[0];
|
||||
var obj = inputs[1];
|
||||
// Setup: Figure out the test string
|
||||
string testString = obj.ToString();
|
||||
|
||||
// If: I attempt to create a CellUpdate
|
||||
CellUpdate cu = new CellUpdate(col, testString);
|
||||
|
||||
// Then: The value and type should match what we put in
|
||||
Assert.That(cu.Value, Is.InstanceOf(col.DataType));
|
||||
Assert.AreEqual(obj, cu.Value);
|
||||
Assert.AreEqual(testString, cu.ValueAsString);
|
||||
Assert.AreEqual(col, cu.Column);
|
||||
foreach (var inputs in RoundTripTestParams)
|
||||
{
|
||||
|
||||
var col = (DbColumnWrapper)inputs[0];
|
||||
var obj = inputs[1];
|
||||
// Setup: Figure out the test string
|
||||
string testString = obj.ToString();
|
||||
|
||||
// If: I attempt to create a CellUpdate
|
||||
CellUpdate cu = new CellUpdate(col, testString);
|
||||
|
||||
// Then: The value and type should match what we put in
|
||||
Assert.That(cu.Value, Is.InstanceOf(col.DataType));
|
||||
Assert.AreEqual(obj, cu.Value);
|
||||
Assert.AreEqual(testString, cu.ValueAsString);
|
||||
Assert.AreEqual(col, cu.Column);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.ServiceLayer.EditData;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
@@ -335,11 +337,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
string[] outCols = insertMatch.Groups[2].Value.Split(", ");
|
||||
Assert.AreEqual(expectedOutput.ExpectedOutColumns, outCols.Length);
|
||||
Assert.That(outCols, Has.All.StartsWith("inserted."), "Output columns match");
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(insertMatch.Groups[3].Value, Does.StartWith("Insert"), "Output table name matches");
|
||||
Assert.That(insertMatch.Groups[3].Value, Does.EndWith("Output"));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(insertMatch.Groups[3].Value, Does.StartWith("Insert"), "Output table name matches");
|
||||
Assert.That(insertMatch.Groups[3].Value, Does.EndWith("Output"));
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -355,19 +357,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
//
|
||||
string[] outCols = insertMatch.Groups[3].Value.Split(", ");
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.AreEqual(expectedOutput.ExpectedOutColumns, outCols.Length);
|
||||
Assert.That(outCols, Has.All.StartsWith("inserted."), "Output columns match");
|
||||
{
|
||||
Assert.AreEqual(expectedOutput.ExpectedOutColumns, outCols.Length);
|
||||
Assert.That(outCols, Has.All.StartsWith("inserted."), "Output columns match");
|
||||
});
|
||||
|
||||
// In columns match
|
||||
string[] inCols = insertMatch.Groups[2].Value.Split(", ");
|
||||
Assert.AreEqual(expectedOutput.ExpectedInColumns, inCols.Length);
|
||||
|
||||
// Output table name matches
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(insertMatch.Groups[4].Value, Does.StartWith("Insert"));
|
||||
Assert.AreEqual(expectedOutput.ExpectedInColumns, inCols.Length);
|
||||
|
||||
// Output table name matches
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(insertMatch.Groups[4].Value, Does.StartWith("Insert"));
|
||||
Assert.That(insertMatch.Groups[4].Value, Does.EndWith("Output"));
|
||||
});
|
||||
|
||||
@@ -469,9 +471,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
Assert.AreEqual(rc.newCells.Length, er.Cells.Length);
|
||||
Assert.AreEqual(SR.EditDataComputedColumnPlaceholder, er.Cells[0].DisplayValue);
|
||||
Assert.False(er.Cells[0].IsNull);
|
||||
Assert.True(er.Cells[0].IsDirty);
|
||||
|
||||
// ... The rest of the cells should have empty display values
|
||||
Assert.True(er.Cells[0].IsDirty);
|
||||
|
||||
// ... The rest of the cells should have empty display values
|
||||
Assert.That(er.Cells.Skip(1).Select(ec => new { ec.DisplayValue, ec.IsNull, ec.IsDirty }), Has.All.EqualTo(new { DisplayValue = string.Empty, IsNull = false, IsDirty = true }));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
@@ -296,8 +298,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
string[] setCols = updateMatch.Groups[2].Value.Split(", ");
|
||||
Assert.AreEqual(3, setCols.Length);
|
||||
Assert.That(setCols, Has.All.Match(@".+ = @Value\d+_\d+"), "Set columns match");
|
||||
|
||||
// Output table name matches
|
||||
|
||||
// Output table name matches
|
||||
Assert.That(updateMatch.Groups[4].Value, Does.StartWith("Update"));
|
||||
Assert.That(updateMatch.Groups[4].Value, Does.EndWith("Output"));
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
@@ -283,8 +285,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
ObjectType = objType
|
||||
};
|
||||
var contextMock = RequestContextMocks.Create<EditInitializeResult>(null);
|
||||
// ... And I initialize an edit session with that
|
||||
// Then:
|
||||
// ... And I initialize an edit session with that
|
||||
// Then:
|
||||
// ... An error event should have been sent
|
||||
Assert.That(() => eds.HandleInitializeRequest(initParams, contextMock.Object), Throws.ArgumentException);
|
||||
|
||||
@@ -308,13 +310,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
ObjectType = "Table",
|
||||
Filters = new EditInitializeFiltering()
|
||||
};
|
||||
var contextMock = RequestContextMocks.Create<EditInitializeResult>(null);
|
||||
|
||||
// Then:
|
||||
// ... An error event should have been sent
|
||||
Assert.That(() => eds.HandleInitializeRequest(initParams, contextMock.Object), Throws.ArgumentNullException);
|
||||
|
||||
// ... The original session should still be there
|
||||
var contextMock = RequestContextMocks.Create<EditInitializeResult>(null);
|
||||
|
||||
// Then:
|
||||
// ... An error event should have been sent
|
||||
Assert.That(() => eds.HandleInitializeRequest(initParams, contextMock.Object), Throws.ArgumentNullException);
|
||||
|
||||
// ... The original session should still be there
|
||||
Assert.AreEqual(1, eds.ActiveSessions.Count);
|
||||
Assert.AreEqual(session, eds.ActiveSessions[Constants.OwnerUri]);
|
||||
}
|
||||
@@ -378,15 +380,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
// ... The session should have been created
|
||||
Assert.AreEqual(1, eds.ActiveSessions.Count);
|
||||
Assert.True(eds.ActiveSessions.Keys.Contains(Constants.OwnerUri));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private static readonly object[] schemaNameParameters =
|
||||
{
|
||||
private static readonly object[] schemaNameParameters =
|
||||
{
|
||||
new object[] {"table", "myschema", new[] { "myschema", "table" } }, // Use schema
|
||||
new object[] {"table", null, new[] { "table" } }, // skip schema
|
||||
new object[] {"schema.table", "myschema", new[] { "myschema", "schema.table" } }, // Use schema
|
||||
new object[] {"schema.table", null, new[] { "schema", "table" } }, // Split object name into schema
|
||||
new object[] {"schema.table", null, new[] { "schema", "table" } }, // Split object name into schema
|
||||
};
|
||||
|
||||
[Test, TestCaseSource(nameof(schemaNameParameters))]
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
|
||||
Reference in New Issue
Block a user