Implement bold font; make tests pass again.

- NEU: Überschriften und pathologische Werte werden fett gedruckt.
- FIX: Kleinere Bugfixes.
This commit is contained in:
Daniel Kraus
2015-08-14 11:22:11 +02:00
parent 39e8b1f81d
commit 32d4e8d955
8 changed files with 100 additions and 16 deletions

View File

@ -24,6 +24,7 @@ using Microsoft.Office.Interop.Word;
using zaaReloaded2.LabModel;
using zaaReloaded2.Formatter;
using zaa = zaaReloaded2.Controller.Elements;
using System.Text.RegularExpressions;
namespace Tests.Controller.Elements
{
@ -62,8 +63,10 @@ namespace Tests.Controller.Elements
_formatter.Settings.Elements.Add(new zaa.Items("Na, K, Cl"));
_formatter.Run();
string expected = (
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) +
"Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r");
StripMarkup(
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) +
"Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r")
);
Assert.AreEqual(expected, _document.Range().Text);
}
@ -82,8 +85,10 @@ namespace Tests.Controller.Elements
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl"));
_formatter.Run();
string expected = (
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) +
"Klinische Chemie: Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r");
StripMarkup(
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) +
"Klinische Chemie: Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r")
);
Assert.AreEqual(expected, _document.Range().Text);
}
@ -120,7 +125,9 @@ namespace Tests.Controller.Elements
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, *"));
_formatter.Run();
string expected = (
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) +
StripMarkup(
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00))
) +
"Klinische Chemie: Na 133, Cl 110, K 6\r\r").Replace(Environment.NewLine, "\r");
Assert.AreEqual(expected, _document.Range().Text);
}
@ -142,7 +149,9 @@ namespace Tests.Controller.Elements
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*"));
_formatter.Run();
string expected = (
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) +
StripMarkup(
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00))
)+
"Klinische Chemie: Na 133, SU-Protein 2,8\r\r").Replace(Environment.NewLine, "\r");
Assert.AreEqual(expected, _document.Range().Text);
}
@ -164,10 +173,19 @@ namespace Tests.Controller.Elements
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*, *"));
_formatter.Run();
string expected = (
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) +
StripMarkup(
TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00))
) +
"Klinische Chemie: Na 133, SU-Protein 2,8, Cl 110, U-Na 99\r\r")
.Replace(Environment.NewLine, "\r");
Assert.AreEqual(expected, _document.Range().Text);
}
static string StripMarkup(string s)
{
return _markupStripper.Replace(s, string.Empty);
}
static readonly Regex _markupStripper = new Regex(@"</?b>");
}
}

View File

@ -21,6 +21,7 @@ using System.Linq;
using System.Text;
using NUnit.Framework;
using zaaReloaded2.Formatter;
using Microsoft.Office.Interop.Word;
namespace Tests.Formatter
{
@ -95,5 +96,13 @@ namespace Tests.Formatter
Assert.IsFalse(_docWriter.HasBufferedText);
Assert.AreEqual(String.Empty, _docWriter.ToString());
}
[Test]
public void TextMarkup()
{
_docWriter.Document = new Document();
_docWriter.WriteLine("This is not bold. <b>This is bold!</b>");
_docWriter.Flush();
}
}
}

View File

@ -65,7 +65,12 @@ namespace Tests.ViewModels
Assert.AreNotSame(orig, copy);
Assert.AreNotSame(orig.RevealModelObject(), copy.RevealModelObject());
Assert.AreEqual(String.Format("Kopie von {0}", orig.Name), copy.Name);
Assert.AreEqual(
String.Format(
"Kopie von {0}",
orig.Name.Replace(" (eingebaut)", String.Empty)
),
copy.Name);
Assert.IsTrue(copy.IsSelected);
}
}