public void FillTemplate_HtmlTemplate_ShouldPass() { var template = new Template(new List<string> {"hemoglobin", "erythrocytes"}, "BloodTest"); var person = new Person("Igor", "Shein", new DateTime(1994, 4, 20), "Yaroslavl", "123456789"); var analysis = new Analysis(new List<string> {"20", "50"}, "Blood Test", new DateTime(2014, 08, 3)); var templateFiller = new TemplateFiller("Blood Test.html"); string actual = templateFiller.FillTemplate(person, analysis, template); //File.WriteAllText("expected.html", actual); string expected = File.ReadAllText("expected.html"); Assert.Equal(expected, actual); }
private void AnalysisExportOKButton_Click(object sender, RoutedEventArgs e) { string currentPrinterName = GetSelectedItem(); if (currentPrinterName == null) { //LOGGING Logger.Info("Analysis was not exported. Printer's name was not initialized"); return; } Printer printer = PrintersLoader.LoadPrinter( Path.Combine(Environment.CurrentDirectory, @"Printers\", currentPrinterName) + ".dll"); if (printer == null) { //LOGGING Logger.Warn("Analysis was not exported. Uncorrect printer"); MessageBox.Show("Incorrect printer!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (_currentAnalysis == null) { //LOGGING Logger.Warn("Analysis was not exported. Current Analysis was not selected."); MessageBox.Show("You must select an analysis!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } var exportSaveFileDialog = new SaveFileDialog { Filter = "All files (*.*)|*.*", FilterIndex = 2, RestoreDirectory = true, Title = "Please enter a name of exported file" }; if (exportSaveFileDialog.ShowDialog() == true) { printer.PathToFile = exportSaveFileDialog.FileName; try { string pathToCurrentHtmlTemplate = Path.Combine(Environment.CurrentDirectory, @"Templates\", _currentTemplate.Title + ".html"); var templateFiller = new TemplateFiller(pathToCurrentHtmlTemplate); printer.Print(templateFiller.FillTemplate(_currentPerson, _currentAnalysis, _currentTemplate)); //LOGGING Logger.Info("Analysis was exporeted."); } catch (Exception ex) { //LOGGING Logger.Info("Analysis was not exporeted. Unknown exception."); MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } MessageBox.Show("Analysis exported successfully!", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } }