public void ContentTypeIsDeducedFromFileExtension() { const string fileExtension = ".ext"; var file = MockFor <IFile>(MockBehavior.Loose); file.SetupGet(_ => _.Extension).Returns(fileExtension); file.Setup(_ => _.ReadAllText()).Returns("text"); var contentType = MockFor <IContentType>(); var contentTypeRegistry = MockFor <IContentTypeRegistry>(); contentTypeRegistry .Setup(_ => _.ForFileExtension(fileExtension)) .Returns(contentType.Object); var factory = new TextDocumentFactory { ContentTypeRegistry = contentTypeRegistry.Object }; var document = factory.ForFile(file.Object); Assert.AreSame(contentType.Object, document.Buffer.ContentType); VerifyAllMocks(); }
public ITextViewDocument DocumentForFile(IFile file) { var document = TextDocumentFactory.ForFile(file); var classifier = ClassifierFor(document.Buffer); var caret = CaretFactory.CaretForBuffer(document.Buffer); return(new TextViewDocument(document, caret, classifier, ClassificationStyler)); }