static UnitTestTextEditorExtension Setup(string input, out TestViewContent content) { TestWorkbenchWindow tww = new TestWorkbenchWindow(); content = new TestViewContent(); tww.ViewContent = content; content.ContentName = "a.cs"; content.GetTextEditorData().Document.MimeType = "text/x-csharp"; Document doc = new Document(tww); var text = @"namespace NUnit.Framework { using System; class TestFixtureAttribute : Attribute {} class TestAttribute : Attribute {} } namespace Test { " + input + "}"; int endPos = text.IndexOf('$'); if (endPos >= 0) { text = text.Substring(0, endPos) + text.Substring(endPos + 1); } content.Text = text; content.CursorPosition = System.Math.Max(0, endPos); var compExt = new UnitTestTextEditorExtension(); compExt.Initialize(doc); content.Contents.Add(compExt); doc.UpdateParseDocument(); return(compExt); }
static async Task <UnitTestTextEditorExtension> Setup(string input) { var tww = new TestWorkbenchWindow(); var content = new TestViewContent(); tww.ViewContent = content; content.ContentName = "/a.cs"; content.Data.MimeType = "text/x-csharp"; MonoDevelop.AnalysisCore.AnalysisOptions.EnableUnitTestEditorIntegration.Set(true); var doc = new Document(tww); var text = @"namespace NUnit.Framework { public class TestFixtureAttribute : System.Attribute {} public class TestAttribute : System.Attribute {} } namespace TestNs { " + input + "}"; int endPos = text.IndexOf('$'); if (endPos >= 0) { text = text.Substring(0, endPos) + text.Substring(endPos + 1); } content.Text = text; content.CursorPosition = System.Math.Max(0, endPos); var project = MonoDevelop.Ide.Services.ProjectService.CreateDotNetProject("C#"); project.Name = "test"; project.FileName = "test.csproj"; project.Files.Add(new ProjectFile("/a.cs", BuildAction.Compile)); var solution = new Solution(); solution.AddConfiguration("", true); solution.DefaultSolutionFolder.AddItem(project); using (var monitor = new ProgressMonitor()) await TypeSystemService.Load(solution, monitor); content.Project = project; doc.SetProject(project); var compExt = new UnitTestTextEditorExtension(); compExt.Initialize(doc.Editor, doc); content.Contents.Add(compExt); await doc.UpdateParseDocument(); TypeSystemService.Unload(solution); return(compExt); }