/
MsSqlServiceClientTests.cs
50 lines (45 loc) · 1.6 KB
/
MsSqlServiceClientTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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;
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 = ToolsServiceClient.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.AbsolutePath);
docChange.TextDocument.Version
.Should()
.Be(1);
}
}