コード例 #1
0
        public void ExportFileTest()
        {
            TexCompiler tc = new TexCompiler();
            //MainWindowVM parent = new MainWindowVM(tc); // TODO: Initialize to an appropriate value
            TEDocumentVM target = new TEDocumentVM(null, tc);

            GlobalUI.MockResult  = MessageBoxResult.Cancel;
            GlobalUI.LastMessage = "";
            string jpgfile = GlobalUI.MockFileDialogFileName = Directory.GetCurrentDirectory() + "\\test.jpg";

            if (File.Exists(jpgfile))
            {
                File.Delete(jpgfile);
            }
            GlobalUI.MockFileDialogResult = true;
            target.ExportFileCommand.Execute(null);
            Assert.IsTrue(File.Exists(jpgfile));

            // now save file, and try again with different extension
            string filename = GlobalUI.MockFileDialogFileName = Directory.GetCurrentDirectory() + "\\" + "temp2.tex";

            GlobalUI.MockFileDialogResult = true;
            target.SaveCurFile();

            jpgfile = GlobalUI.MockFileDialogFileName = GlobalUI.MockFileDialogFileName = Directory.GetCurrentDirectory() + "\\test.png";
            if (File.Exists(jpgfile))
            {
                File.Delete(jpgfile);
            }
            target.ExportFileCommand.Execute(null);
            // check that file is actually there
            Assert.IsTrue(File.Exists(jpgfile));
        }
コード例 #2
0
        public void TryDisposeFileTest()
        {
            TexCompiler tc = new TexCompiler();
            //MainWindowVM parent = new MainWindowVM(tc); // TODO: Initialize to an appropriate value
            TEDocumentVM target = new TEDocumentVM(null, tc);

            GlobalUI.MockResult  = MessageBoxResult.Cancel;
            GlobalUI.LastMessage = "";

            // no changes made -> user should not be asked
            bool ret = target.TryDisposeFile();

            Assert.AreEqual(GlobalUI.LastMessage, "");
            Assert.IsTrue(ret);

            // make a change
            target.Document.Insert(0, " ");
            ret = target.TryDisposeFile();
            Assert.AreNotEqual(GlobalUI.LastMessage, "");
            Assert.IsFalse(ret);
            Assert.IsTrue(target.ChangesMade);

            // say we don't want to save changes
            GlobalUI.MockResult = MessageBoxResult.No;
            ret = target.TryDisposeFile();
            Assert.IsTrue(ret);
        }
コード例 #3
0
        public void SavePdfTest()
        {
            TexCompiler tc = new TexCompiler();
            //MainWindowVM parent = new MainWindowVM(tc); // TODO: Initialize to an appropriate value
            string       cFile  = string.Empty; // TODO: Initialize to an appropriate value
            TEDocumentVM target = new TEDocumentVM(null, tc);

            GlobalUI.MockResult  = MessageBoxResult.Cancel;
            GlobalUI.LastMessage = "";
            // try to save pdf -> should not work, file should be saved first
            string pdffile = target.SavePdf(false);

            Assert.AreEqual("", pdffile);

            // now save file
            string filename = GlobalUI.MockFileDialogFileName = Directory.GetCurrentDirectory() + "\\" + "temp2.tex";

            GlobalUI.MockFileDialogResult = true;
            target.SaveCurFile();

            pdffile = target.SavePdf(false);
            Assert.That(pdffile, Is.EqualTo(Helper.RemoveFileExtension(filename) + ".pdf").IgnoreCase);

            // check that file is actually there
            Assert.IsTrue(File.Exists(pdffile));
        }
コード例 #4
0
        public void SavePdfTest()
        {
            TexCompiler tc = new TexCompiler();
            //MainWindowVM parent = new MainWindowVM(tc); // TODO: Initialize to an appropriate value
            string cFile = string.Empty; // TODO: Initialize to an appropriate value
            TEDocumentVM <AvalonDocumentWrapper> target = new TEDocumentVM <AvalonDocumentWrapper>(null, tc);
            string filename = GlobUI.MockFileDialogFileName = Directory.GetCurrentDirectory() + "\\" + "temp2.tex";

            GlobUI.MockFileDialogResult = true;
            target.SaveCurFile();

            Thread.Sleep(1000);

            target.SavePdf(false);

            Assert.IsTrue(File.Exists(Helper.RemoveFileExtension(filename) + ".pdf"));
        }