private ITextBuffer CreateValidMefTextBuffer(ITextDocument textDocument) { var newTextBufferMock = new Mock <ITextBuffer>(); var bufferProps = new Microsoft.VisualStudio.Utilities.PropertyCollection(); bufferProps.AddProperty(typeof(ITextDocument), textDocument); newTextBufferMock.Setup(x => x.Properties).Returns(bufferProps); return(newTextBufferMock.Object); }
private static ITextView CreateValidTextView(ITextBuffer buffer = null) { var viewMock = new Mock <ITextView>(); var properties = new Microsoft.VisualStudio.Utilities.PropertyCollection(); viewMock.Setup(x => x.Properties).Returns(properties); viewMock.Setup(x => x.TextBuffer).Returns(buffer); viewMock.As <IWpfTextView>(); return(viewMock.Object); }
public static Mock <ITextBuffer> CreateBufferMock(int length = 999, string filePath = "test.cpp") { var snapshotMock = new Mock <ITextSnapshot>(); var bufferMock = new Mock <ITextBuffer>(); bufferMock.Setup(x => x.CurrentSnapshot).Returns(snapshotMock.Object); snapshotMock.Setup(x => x.TextBuffer).Returns(bufferMock.Object); snapshotMock.Setup(x => x.Length).Returns(length); var properties = new Microsoft.VisualStudio.Utilities.PropertyCollection(); bufferMock.Setup(x => x.Properties).Returns(properties); var docMock = new Mock <ITextDocument>(); docMock.Setup(x => x.FilePath).Returns(filePath); properties[typeof(ITextDocument)] = docMock.Object; return(bufferMock); }