private async Task <RenameResponse> SendRequest(OmnisharpWorkspace workspace, string renameTo, string filename, string fileContent, bool wantsTextChanges = false, bool applyTextChanges = true) { var lineColumn = TestHelpers.GetLineAndColumnFromDollar(fileContent); var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions()); var request = new RenameRequest { Line = lineColumn.Line, Column = lineColumn.Column, RenameTo = renameTo, FileName = filename, Buffer = fileContent.Replace("$", ""), WantsTextChanges = wantsTextChanges, ApplyTextChanges = applyTextChanges }; var bufferFilter = new UpdateBufferFilter(workspace); bufferFilter.OnActionExecuting(TestHelpers.CreateActionExecutingContext(request, controller)); return(await controller.Rename(request)); }
private async Task <string> GetTestCommandArgumentsAsync(string source, TestCommandType testType = TestCommandType.Single) { var workspace = TestHelpers.CreateSimpleWorkspace(source); var context = new DnxContext(); var projectName = "project.json"; var projectCounter = 1; context.ProjectContextMapping.Add(projectName, projectCounter); context.Projects.Add(projectCounter, new Project { Path = "project.json", Commands = { { "test", "Xunit.KRunner" } } }); var testCommandProviders = new[] { new DnxTestCommandProvider(context, new FakeEnvironment(), new FakeLoggerFactory(), new NullEventEmitter(), new FakeOmniSharpOptions()) }; var controller = new TestCommandController(workspace, testCommandProviders); var lineColumn = TestHelpers.GetLineAndColumnFromDollar(source); var request = new TestCommandRequest { Line = lineColumn.Line, Column = lineColumn.Column, FileName = "dummy.cs", Buffer = source.Replace("$", ""), Type = testType }; var bufferFilter = new UpdateBufferFilter(workspace); bufferFilter.OnActionExecuting(TestHelpers.CreateActionExecutingContext(request, controller)); var testCommand = await controller.GetTestCommand(request); return(testCommand.TestCommand); }
private Request CreateRequest(string source, string fileName = "dummy.cs") { var lineColumn = TestHelpers.GetLineAndColumnFromDollar(source); return(new Request { Line = lineColumn.Line, Column = lineColumn.Column, FileName = fileName, Buffer = source.Replace("$", "") }); }
private FindUsagesRequest CreateRequest(string source, string fileName = "dummy.cs", bool excludeDefinition = false) { var lineColumn = TestHelpers.GetLineAndColumnFromDollar(source); return(new FindUsagesRequest { Line = lineColumn.Line, Column = lineColumn.Column, FileName = fileName, Buffer = source.Replace("$", ""), OnlyThisFile = false, ExcludeDefinition = excludeDefinition }); }
private AutoCompleteRequest CreateRequest(string source, string fileName = "dummy.cs") { var lineColumn = TestHelpers.GetLineAndColumnFromDollar(source); return(new AutoCompleteRequest { Line = lineColumn.Line, Column = lineColumn.Column, FileName = fileName, Buffer = source.Replace("$", ""), WordToComplete = GetPartialWord(source), WantMethodHeader = true }); }
private async Task <SignatureHelp> GetSignatureHelp(string source) { var lineColumn = TestHelpers.GetLineAndColumnFromDollar(source); source = source.Replace("$", string.Empty); var request = new Request() { FileName = "dummy.cs", Line = lineColumn.Line, Column = lineColumn.Column, Buffer = source }; var workspace = TestHelpers.CreateSimpleWorkspace(source); var controller = new OmnisharpController(workspace, null); return(await controller.GetSignatureHelp(request)); }
private async Task <NavigateResponse> SendRequest(OmnisharpWorkspace workspace, string fileName, string fileContent, NavigateDirection upOrDown) { var initialCursorLineColumn = TestHelpers.GetLineAndColumnFromDollar(TestHelpers.RemovePercentMarker(fileContent)); var fileContentNoDollarMarker = TestHelpers.RemoveDollarMarker(fileContent); var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions()); var request = new Request { Line = initialCursorLineColumn.Line, Column = initialCursorLineColumn.Column, FileName = fileName, Buffer = fileContentNoDollarMarker }; if (upOrDown == NavigateDirection.UP) { return(await controller.NavigateUp(request)); } else { return(await controller.NavigateDown(request)); } }
public async Task FixUsings_ReturnsAmbiguousResult() { const string fileContents = @" namespace nsA { public class classX{} } namespace nsB { public class classX{} } namespace OmniSharp { public class class1 { public method1() { var c1 = new $classX(); } } }"; var classLineColumn = TestHelpers.GetLineAndColumnFromDollar(TestHelpers.RemovePercentMarker(fileContents)); var fileContentNoDollarMarker = TestHelpers.RemoveDollarMarker(fileContents); var expectedUnresolved = new List <QuickFix>(); expectedUnresolved.Add(new QuickFix() { Line = classLineColumn.Line, Column = classLineColumn.Column, FileName = fileName, Text = "`classX` is ambiguous" }); await AssertUnresolvedReferences(fileContentNoDollarMarker, expectedUnresolved); }