mirrorsharp/Tests.Shared/MoveCursorHandlerTests.cs

51 строка
2.0 KiB
C#
Исходник Обычный вид История

using System.Linq;
using System.Threading.Tasks;
using MirrorSharp.Internal;
using MirrorSharp.Testing;
using MirrorSharp.Testing.Internal.Results;
using Xunit;
namespace MirrorSharp.Tests {
using static CommandIds;
public class MoveCursorHandlerTests {
[Theory]
[InlineData("1", 1)]
[InlineData("79", 79)]
[InlineData("1234567890", 1234567890)]
public async void ExecuteAsync_UpdatesSessionCursorPosition(string dataString, int expectedPosition) {
2017-01-03 02:33:48 +03:00
var driver = MirrorSharpTestDriver.New();
await driver.SendAsync(MoveCursor, dataString);
Assert.Equal(expectedPosition, driver.Session.CursorPosition);
}
[Fact]
public async Task ExecuteAsync_ProducesEmptySignatureHelp_IfCursorIsMovedOutsideOfSignatureSpan() {
2017-05-13 15:57:31 +03:00
var driver = MirrorSharpTestDriver.New().SetTextWithCursor(@"
class C {
void M() {}
void T() { M| }
}
");
2017-01-03 02:33:48 +03:00
var signatures = await driver.SendAsync<SignaturesResult>(TypeChar, '(');
var result = await driver.SendAsync<SignaturesResult>(MoveCursor, signatures.Span.Start - 1);
Assert.Equal(0, result.Signatures.Count);
}
[Fact]
public async Task ExecuteAsync_ProducesSignatureHelpWithNewSelectedParameter_IfCursorIsMovedMovedBetweenParameters() {
2017-05-13 15:57:31 +03:00
var driver = MirrorSharpTestDriver.New().SetTextWithCursor(@"
class C {
void M(int a, int b, int c) {}
void T() { M(1| }
}
");
await driver.SendTypeCharsAsync(",2,");
2017-01-03 02:33:48 +03:00
var result = await driver.SendAsync<SignaturesResult>(MoveCursor, driver.Session.CursorPosition - 1);
var signature = result.Signatures.Single();
Assert.Equal("void C.M(int a, *int b*, int c)", signature.ToString());
}
}
}