public void PropertyChangedEventTest()
        {
            var viewModel = Container.GetExportedValue<RichTextViewModel>();
            RichTextDocumentType documentType = new RichTextDocumentType();
            RichTextDocument document = new RichTextDocument(documentType);
            viewModel.Document = document;

            Assert.AreEqual(document, viewModel.Document);

            AssertHelper.PropertyChangedEvent(viewModel, x => x.IsBold, () => viewModel.IsBold = true);
            Assert.IsTrue(viewModel.IsBold);

            AssertHelper.PropertyChangedEvent(viewModel, x => x.IsItalic, () => viewModel.IsItalic = true);
            Assert.IsTrue(viewModel.IsItalic);

            AssertHelper.PropertyChangedEvent(viewModel, x => x.IsUnderline, () => viewModel.IsUnderline = true);
            Assert.IsTrue(viewModel.IsUnderline);

            AssertHelper.PropertyChangedEvent(viewModel, x => x.IsNumberedList, () => viewModel.IsNumberedList = true);
            Assert.IsTrue(viewModel.IsNumberedList);

            AssertHelper.PropertyChangedEvent(viewModel, x => x.IsBulletList, () => viewModel.IsBulletList = true);
            Assert.IsTrue(viewModel.IsBulletList);

            AssertHelper.PropertyChangedEvent(viewModel, x => x.IsSpellCheckEnabled, () => viewModel.IsSpellCheckEnabled = true);
            Assert.IsTrue(viewModel.IsSpellCheckEnabled);
        }
 public void NewDocumentTest()
 {
     RichTextDocumentType documentType = new RichTextDocumentType();
     Assert.IsTrue(documentType.CanNew());
     RichTextDocument document = documentType.New() as RichTextDocument;
     Assert.IsNotNull(document);
     Assert.AreEqual("Document 1.rtf", document.FileName);
 }
        public void DocumentTest()
        {
            RichTextDocumentType documentType = new RichTextDocumentType();
            IDocument document = documentType.New();

            Assert.AreEqual(document.DocumentType, documentType);

            Assert.AreEqual("Document 1.rtf", document.FileName);
            AssertHelper.PropertyChangedEvent(document, x => x.FileName, () => document.FileName = "Document 2.rtf");
            Assert.AreEqual("Document 2.rtf", document.FileName);

            Assert.IsFalse(document.Modified);
            AssertHelper.PropertyChangedEvent(document, x => x.Modified, () => document.Modified = true);
            Assert.IsTrue(document.Modified);
        }
        public void SaveDocumentTest()
        {
            RichTextDocumentType rtfDocumentType = new RichTextDocumentType();
            IDocument document = rtfDocumentType.New();
            Assert.AreEqual("Document 1.rtf", document.FileName);

            XpsExportDocumentType xpsDocumentType = new XpsExportDocumentType();
            Assert.IsTrue(xpsDocumentType.CanSave(document));
            xpsDocumentType.Save(document, "TestDocument1.xps");

            // The document file name is still the original one because XPS is just an export format.
            Assert.AreEqual("Document 1.rtf", document.FileName);

            // Note: What's missing is to check the content of TestDocument1.xps.
        }
        public void SaveAndOpenDocumentTest()
        {
            RichTextDocumentType documentType = new RichTextDocumentType();
            IDocument document = documentType.New();
            Assert.AreEqual("Document 1.rtf", document.FileName);

            Assert.IsTrue(documentType.CanSave(document));
            documentType.Save(document, "TestDocument1.rtf");
            Assert.AreEqual("TestDocument1.rtf", document.FileName);

            Assert.IsTrue(documentType.CanOpen());
            IDocument openedDocument = documentType.Open("TestDocument1.rtf");
            Assert.AreEqual("TestDocument1.rtf", openedDocument.FileName);

            // Note: What's missing is to compare the document content of both documents.
        }
Example #6
0
 public RichTextDocument(RichTextDocumentType documentType) : this(documentType, new FlowDocument())
 {
 }
Example #7
0
 public RichTextDocument(RichTextDocumentType documentType, FlowDocument content) : base(documentType)
 {
     Content = content;
 }
 public void DocumentTypeTest()
 {
     RichTextDocumentType documentType = new RichTextDocumentType();
     Assert.AreEqual(".rtf", documentType.FileExtension);
     Assert.AreEqual("RichText Documents (*.rtf)", documentType.Description);
 }
Example #9
0
 public RichTextDocument(RichTextDocumentType documentType, FlowDocument content = null) : base(documentType)
 {
     Content = content ?? new FlowDocument();
 }
Example #10
0
 public RichTextDocument(RichTextDocumentType documentType) : this(documentType, new FlowDocument())
 {
 }
Example #11
0
 public RichTextDocument(RichTextDocumentType documentType, FlowDocument content) : base(documentType)
 {
     Content = content;
 }