Пример #1
0
		public void TextEditorDocumentGetTextReturnsCorrectSectionOfText()
		{
			TextSection expectedSection = new TextSection(0, 5);
			
			MockDocument document = new MockDocument();
			document.Text = "abcdefghi";
			
			Assert.AreEqual("def", document.GetText(3, 3));
		}
Пример #2
0
		public void CreateTextEditorSnapshot_DocumentHasFakeSnapshot_ReturnsFakeSnapshot()
		{
			CreateXmlFoldingManager();
			
			MockDocument expectedSnapshot = new MockDocument();
			fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot);
			
			ITextSource snapshot = xmlFoldingManager.CreateTextEditorSnapshot();
			
			Assert.AreEqual(expectedSnapshot, snapshot);
		}
Пример #3
0
		public void GetFolds_FakeXmlFoldParserUsed_ReturnsFoldsFromFakeXmlFoldParser()
		{
			CreateXmlFoldingManager();
			FoldingRegion fold = CreateFoldingRegion();
			fakeXmlFoldParser.Folds.Add(fold);
			
			MockDocument expectedSnapshot = new MockDocument();
			fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot);
			
			ITextSource snapshot = xmlFoldingManager.CreateTextEditorSnapshot();
			
			IList<FoldingRegion> folds = xmlFoldingManager.GetFolds(snapshot);
			
			Assert.AreEqual(fakeXmlFoldParser.Folds, folds);
		}
Пример #4
0
		public void UpdateFolds_NoParameterPassedToMethod_FakeXmlFoldParserFoldsUsedToUpdateFakeFoldingManager()
		{
			CreateXmlFoldingManager();
			AddDocumentPositionToOffsetReturnValue(5);
			AddDocumentPositionToOffsetReturnValue(10);
			
			MockDocument expectedSnapshot = new MockDocument();
			fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot);
			
			FoldingRegion fold = CreateTestFoldingRegion();
			fakeXmlFoldParser.Folds.Add(fold);
			
			xmlFoldingManager.UpdateFolds();			

			IList<NewFolding> newFolds = fakeFoldingManager.NewFoldsPassedToUpdateFoldings;
			
			List<NewFolding> expectedFolds = CreateTestNewFoldingList();
			
			NewFoldingHelper.AssertAreEqual(expectedFolds, newFolds);
		}
Пример #5
0
		public void UpdateFolds_XmlFoldParserReturnsNullFromGetFolds_FoldingManagerFoldsAreNotUpdated()
		{
			CreateXmlFoldingManager();
			
			MockDocument expectedSnapshot = new MockDocument();
			fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot);
			fakeXmlFoldParser.Folds = null;
			
			xmlFoldingManager.UpdateFolds();
			
			bool result = fakeFoldingManager.IsUpdateFoldingsCalled;
			
			Assert.IsFalse(result);
		}
Пример #6
0
		public void UpdateFolds_NoParameterPassedToMethod_SnapshotPassedToXmlFoldParser()
		{
			CreateXmlFoldingManager();
			AddDocumentPositionToOffsetReturnValue(5);
			AddDocumentPositionToOffsetReturnValue(10);
						
			MockDocument expectedSnapshot = new MockDocument();
			fakeTextEditor.MockDocument.SetSnapshot(expectedSnapshot);
						
			FoldingRegion fold = CreateTestFoldingRegion();
			fakeXmlFoldParser.Folds.Add(fold);
			
			xmlFoldingManager.UpdateFolds();			
			
			Assert.AreEqual(expectedSnapshot, fakeXmlFoldParser.TextBufferPassedToGetFolds);
		}
		public void CanReplaceDocumentObjectUsed()
		{
			MockDocument doc = new MockDocument();
			editor.SetDocument(doc);
			Assert.AreSame(doc, editor.Document);
		}
Пример #8
0
		public void Init()
		{
			document = new MockDocument();
		}