-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve intellisense behavior for MSSQL kernel. (#1062)
* Improve intellisense behavior for MSSQL code. * Improve parsing for line endings. * Add unit tests for intellisense changes. * Use Theory attribute instead of separate tests. Also replaced Equals() assertion with Be().
- Loading branch information
Showing
2 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/Microsoft.DotNet.Interactive.SqlServer.Tests/MsSqlServiceClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Xunit; | ||
using FluentAssertions; | ||
using System.IO; | ||
|
||
namespace Microsoft.DotNet.Interactive.SqlServer.Tests | ||
{ | ||
public class MsSqlServiceClientTests | ||
{ | ||
[Theory] | ||
[InlineData("\r\n")] | ||
[InlineData("\n")] | ||
public void Should_parse_doc_change_correctly_with_different_line_endings(string lineEnding) | ||
{ | ||
string oldText = string.Join(lineEnding, "abc", "def", "", "abc", "abcdef"); | ||
int oldTextLineCount = 5; | ||
int oldTextLastCharacterNum = 6; | ||
string newText = string.Join(lineEnding, "abc", "def"); | ||
var testUri = new Uri("untitled://test"); | ||
|
||
var docChange = MsSqlServiceClient.GetDocumentChangeForText(testUri, newText, oldText); | ||
|
||
docChange.ContentChanges.Length | ||
.Should() | ||
.Be(1); | ||
docChange.ContentChanges[0].Range.End.Line | ||
.Should() | ||
.Be(oldTextLineCount - 1); | ||
docChange.ContentChanges[0].Range.End.Character | ||
.Should() | ||
.Be(oldTextLastCharacterNum); | ||
docChange.ContentChanges[0].Range.Start.Line | ||
.Should() | ||
.Be(0); | ||
docChange.ContentChanges[0].Range.Start.Character | ||
.Should() | ||
.Be(0); | ||
docChange.ContentChanges[0].Text | ||
.Should() | ||
.Be(newText); | ||
docChange.TextDocument.Uri | ||
.Should() | ||
.Be(testUri.ToString()); | ||
docChange.TextDocument.Version | ||
.Should() | ||
.Be(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters