public void SetUp() { SD.InitializeForUnitTests(); textEditor = new MockTextEditor(); textEditor.Document.Text = program; var parseInfo = textEditor.CreateParseInformation(); this.project = MockRepository.GenerateStrictMock <IProject>(); var pc = new CSharpProjectContent().AddOrUpdateFiles(parseInfo.UnresolvedFile); pc = pc.AddAssemblyReferences(new[] { Corlib }); var compilation = pc.CreateCompilation(); SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock <IParserService>()); SD.ParserService.Stub(p => p.GetCachedParseInformation(textEditor.FileName)).Return(parseInfo); SD.ParserService.Stub(p => p.GetCompilation(project)).Return(compilation); SD.ParserService.Stub(p => p.GetCompilationForFile(textEditor.FileName)).Return(compilation); SD.ParserService.Stub(p => p.Parse(textEditor.FileName, textEditor.Document)).WhenCalled( i => { var syntaxTree = new CSharpParser().Parse(textEditor.Document, textEditor.FileName); i.ReturnValue = new CSharpFullParseInformation(syntaxTree.ToTypeSystem(), null, syntaxTree); }).Return(parseInfo); // fake Return to make it work SD.Services.AddService(typeof(IFileService), MockRepository.GenerateStrictMock <IFileService>()); IViewContent view = MockRepository.GenerateStrictMock <IViewContent>(); view.Stub(v => v.GetService(typeof(ITextEditor))).Return(textEditor); SD.FileService.Stub(f => f.OpenFile(textEditor.FileName, false)).Return(view); gen = new CSharpCodeGenerator(); }
public void SetUp() { textEditor = new MockTextEditor(); textEditor.Document.Text = programStart + "override" + programEnd; textEditor.Caret.Offset = programStart.Length + "override".Length; textEditor.CreateParseInformation(); CSharpCompletionBinding completion = new CSharpCompletionBinding(); keyPressResult = completion.HandleKeyPress(textEditor, ' '); }
public void SetUp() { SD.InitializeForUnitTests(); textEditor = new MockTextEditor(); textEditor.Document.Text = programStart + "override " + programEnd; textEditor.Caret.Offset = programStart.Length + "override ".Length; var parseInfo = textEditor.CreateParseInformation(); var pc = new CSharpProjectContent().AddOrUpdateFiles(parseInfo.UnresolvedFile); pc = pc.AddAssemblyReferences(new[] { Corlib }); var compilation = pc.CreateCompilation(); SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock<IParserService>()); SD.ParserService.Stub(p => p.GetCachedParseInformation(textEditor.FileName)).Return(parseInfo); SD.ParserService.Stub(p => p.GetCompilationForFile(textEditor.FileName)).Return(compilation); SD.ParserService.Stub(p => p.Parse(textEditor.FileName, textEditor.Document)).WhenCalled( i => { var syntaxTree = new CSharpParser().Parse(textEditor.Document, textEditor.FileName); i.ReturnValue = new CSharpFullParseInformation(syntaxTree.ToTypeSystem(), null, syntaxTree); }); CSharpCompletionBinding completion = new CSharpCompletionBinding(); keyPressResult = completion.HandleKeyPressed(textEditor, ' '); }
public void SetUp() { SD.InitializeForUnitTests(); textEditor = new MockTextEditor(); textEditor.Document.Text = programStart + "override " + programEnd; textEditor.Caret.Offset = programStart.Length + "override ".Length; var parseInfo = textEditor.CreateParseInformation(); var pc = new CSharpProjectContent().AddOrUpdateFiles(parseInfo.UnresolvedFile); pc = pc.AddAssemblyReferences(new[] { Corlib }); var compilation = pc.CreateCompilation(); SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock <IParserService>()); SD.ParserService.Stub(p => p.GetCachedParseInformation(textEditor.FileName)).Return(parseInfo); SD.ParserService.Stub(p => p.GetCompilationForFile(textEditor.FileName)).Return(compilation); SD.ParserService.Stub(p => p.Parse(textEditor.FileName, textEditor.Document)).WhenCalled( i => { var syntaxTree = new CSharpParser().Parse(textEditor.Document, textEditor.FileName); i.ReturnValue = new CSharpFullParseInformation(syntaxTree.ToTypeSystem(), null, syntaxTree); }); CSharpCompletionBinding completion = new CSharpCompletionBinding(); keyPressResult = completion.HandleKeyPressed(textEditor, ' '); }