forked from OmniSharp/csharp-language-server-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPositionTests.cs
69 lines (57 loc) · 1.92 KB
/
PositionTests.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using FluentAssertions;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using TestingUtils;
using Xunit;
namespace Lsp.Tests.Models
{
public class PositionTests
{
[Theory]
[JsonFixture]
public void SimpleTest(string expected)
{
var model = new Position(1, 1);
var result = Fixture.SerializeObject(model);
result.Should().Be(expected);
var deresult = new LspSerializer(ClientVersion.Lsp3).DeserializeObject<Position>(expected);
deresult.Should().BeEquivalentTo(model, x => x.UsingStructuralRecordEquality());
}
[Fact]
public void Is_Sortable_By_Character()
{
var a = new Position(1, 1);
var b = new Position(1, 2);
var c = new Position(1, 1);
a.Should().BeLessThan(b);
b.Should().BeGreaterThan(a);
a.CompareTo(c).Should().Be(0);
a.Should().BeLessThanOrEqualTo(c);
a.Should().BeGreaterThanOrEqualTo(c);
}
[Fact]
public void Is_Sortable_By_Line()
{
var a = new Position(1, 1);
var b = new Position(2, 1);
var c = new Position(1, 1);
a.Should().BeLessThan(b);
b.Should().BeGreaterThan(a);
a.CompareTo(c).Should().Be(0);
a.Should().BeLessThanOrEqualTo(c);
a.Should().BeGreaterThanOrEqualTo(c);
}
[Fact]
public void Should_Support_Delta()
{
var a = new Position(1, 1);
a = a.Delta(deltaLine: 1);
a.Line.Should().Be(2);
a = a.Delta(deltaCharacter: -1);
a.Character.Should().Be(0);
a = a.Delta(-1, 1);
a.Should().Be((1, 1));
}
}
}