コード例 #1
0
        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();
        }
コード例 #2
0
        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));
        }