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)); }
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)); }
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")); }