public async static Task <TextEditorExtensionTestCase> Create(TestViewContent content, EditorExtensionTestData data, bool wrap) { var test = new TextEditorExtensionTestCase(); await test.Init(content, data, wrap); test.Document = await test.DocumentManager.OpenDocument(content); return(test); }
protected async Task <TextEditorExtensionTestCase> SetupTestCase(string input, int cursorPosition = -1, bool wrap = false) { await Runtime.GetService <CompositionManager> (); var data = GetContentData(); var content = new TestViewContent(); await content.Initialize(new FileDescriptor (data.FileName, null, null)); content.Text = input; content.Editor.MimeType = data.MimeType; if (cursorPosition != -1) { content.CursorPosition = cursorPosition; } var project = Services.ProjectService.CreateDotNetProject(data.Language); project.Name = Path.GetFileNameWithoutExtension(data.ProjectFileName); project.FileName = data.ProjectFileName; project.Files.Add(new ProjectFile(content.FilePath, BuildAction.Compile)); foreach (var reference in data.References) { project.References.Add(ProjectReference.CreateAssemblyReference(reference)); } var solution = new Solution(); solution.AddConfiguration("", true); solution.DefaultSolutionFolder.AddItem(project); content.Owner = project; using (var monitor = new ProgressMonitor()) await IdeApp.TypeSystemService.Load(solution, monitor); var testCase = await TextEditorExtensionTestCase.Create(content, data, wrap); var doc = testCase.Document; foreach (var ext in GetEditorExtensions()) { ext.Initialize(doc.Editor, doc.DocumentContext); content.AddContent(ext); } await doc.DocumentContext.UpdateParseDocument(); return(testCase); }