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, ' ');
		}
Example #3
0
        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 EnterInsideString()
		{
			const string start = "class X {\n" + 
				"\tstring text = \"a";
			const string insertedMiddle = "\" +\n\t\"";
			const string end = "b\";\n" +
				"}";
			MockTextEditor textEditor = new MockTextEditor();
			textEditor.Document.Text = start + end;
			textEditor.Select(start.Length, 0);
			CSharpFormattingStrategy formattingStrategy = new CSharpFormattingStrategy();
			textEditor.TextEditor.TextArea.PerformTextInput("\n");
			formattingStrategy.FormatLine(textEditor, '\n');
			Assert.AreEqual(start + insertedMiddle + end, textEditor.Document.Text);
			Assert.AreEqual(start.Length + insertedMiddle.Length, textEditor.SelectionStart);
			Assert.AreEqual(0, textEditor.SelectionLength);
		}
        public void EnterInsideString()
        {
            const string start = "class X {\n" +
                                 "\tstring text = \"a";
            const string insertedMiddle = "\" +\n\t\"";
            const string end            = "b\";\n" +
                                          "}";
            MockTextEditor textEditor = new MockTextEditor();

            textEditor.Document.Text = start + end;
            textEditor.Select(start.Length, 0);
            CSharpFormattingStrategy formattingStrategy = new CSharpFormattingStrategy();

            textEditor.TextEditor.TextArea.PerformTextInput("\n");
            formattingStrategy.FormatLine(textEditor, '\n');
            Assert.AreEqual(start + insertedMiddle + end, textEditor.Document.Text);
            Assert.AreEqual(start.Length + insertedMiddle.Length, textEditor.SelectionStart);
            Assert.AreEqual(0, textEditor.SelectionLength);
        }
		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, ' ');
        }