More work on Formatter; successful tests.
This commit is contained in:
@ -30,55 +30,72 @@ namespace Tests.Formatter.Elements
|
||||
[TestFixture]
|
||||
class ItemsTest
|
||||
{
|
||||
zaaReloaded2.Formatter.Formatter _formatter;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_formatter = new zaaReloaded2.Formatter.Formatter(new Document());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
((_Document)_formatter.Document).Close(WdSaveOptions.wdDoNotSaveChanges);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemsTestWithoutCaption()
|
||||
{
|
||||
zaa.Items i = new zaa.Items("Na, K, Cl");
|
||||
Laboratory lab = new Laboratory();
|
||||
TimePoint tp = new TimePoint();
|
||||
tp.TimeStamp = new DateTime(2015, 7, 13, 13, 31, 00);
|
||||
tp.AddItem(new LabItem("Na", "133", "133"));
|
||||
tp.AddItem(new LabItem("K", "6", "5"));
|
||||
// We do not add a 'Cl' item, and it should not appear in output.
|
||||
TimePointFormatter tpf = new TimePointFormatter(tp, ReferenceStyle.IfAbnormal);
|
||||
TimePointFormatterDictionary tpfd = new TimePointFormatterDictionary();
|
||||
tpfd.Add(tpf.TimeStamp, tpf);
|
||||
Document document = new Document();
|
||||
i.WriteToDocument(document, tpfd);
|
||||
Assert.AreEqual("Na 133, K 6 (5)\r", document.Range().Text);
|
||||
lab.AddTimePoint(tp);
|
||||
|
||||
_formatter.ReferenceStyle = ReferenceStyle.IfAbnormal;
|
||||
_formatter.Laboratory = lab;
|
||||
_formatter.Elements.Add(new zaa.Items("Na, K, Cl"));
|
||||
_formatter.Run();
|
||||
Assert.AreEqual("Na 133, K 6 (5)\r", _formatter.Document.Range().Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemsTestWithCaption()
|
||||
{
|
||||
zaa.Items i = new zaa.Items("Klinische Chemie: Na, K, Cl");
|
||||
Laboratory lab = new Laboratory();
|
||||
TimePoint tp = new TimePoint();
|
||||
tp.TimeStamp = new DateTime(2015, 7, 13, 13, 31, 00);
|
||||
tp.AddItem(new LabItem("Na", "133", ""));
|
||||
tp.AddItem(new LabItem("K", "6", "5"));
|
||||
// We do not add a 'Cl' item, and it should not appear in output.
|
||||
TimePointFormatter tpf = new TimePointFormatter(tp, ReferenceStyle.IfAbnormal);
|
||||
TimePointFormatterDictionary tpfd = new TimePointFormatterDictionary();
|
||||
tpfd.Add(tpf.TimeStamp, tpf);
|
||||
Document document = new Document();
|
||||
i.WriteToDocument(document, tpfd);
|
||||
Assert.AreEqual("Klinische Chemie: Na 133, K 6 (5)\r", document.Range().Text);
|
||||
lab.AddTimePoint(tp);
|
||||
|
||||
_formatter.ReferenceStyle = ReferenceStyle.IfAbnormal;
|
||||
_formatter.Laboratory = lab;
|
||||
_formatter.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl"));
|
||||
_formatter.Run();
|
||||
Assert.AreEqual("Klinische Chemie: Na 133, K 6 (5)\r", _formatter.Document.Range().Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemsTestWithCaptionButNoItems()
|
||||
{
|
||||
zaa.Items i = new zaa.Items("Klinische Chemie: this, does, not, exist");
|
||||
Laboratory lab = new Laboratory();
|
||||
TimePoint tp = new TimePoint();
|
||||
tp.TimeStamp = new DateTime(2015, 7, 13, 13, 31, 00);
|
||||
tp.AddItem(new LabItem("Na", "133", ""));
|
||||
tp.AddItem(new LabItem("K", "6", "5"));
|
||||
// We do not add a 'Cl' item, and it should not appear in output.
|
||||
TimePointFormatter tpf = new TimePointFormatter(tp, ReferenceStyle.IfAbnormal);
|
||||
TimePointFormatterDictionary tpfd = new TimePointFormatterDictionary();
|
||||
tpfd.Add(tpf.TimeStamp, tpf);
|
||||
Document document = new Document();
|
||||
i.WriteToDocument(document, tpfd);
|
||||
Assert.AreEqual("\r", document.Range().Text);
|
||||
lab.AddTimePoint(tp);
|
||||
|
||||
_formatter.ReferenceStyle = ReferenceStyle.IfAbnormal;
|
||||
_formatter.Laboratory = lab;
|
||||
_formatter.Elements.Add(new zaa.Items("Klinische Chemie: this, does, not, exist"));
|
||||
_formatter.Run();
|
||||
Assert.AreEqual("\r", _formatter.Document.Range().Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,13 +33,14 @@ namespace Tests.Formatter
|
||||
[Test]
|
||||
public void FormatLaboratory()
|
||||
{
|
||||
Document document = new Document();
|
||||
ZaaImporter importer = TestHelpers.ZaaImporterFromResource();
|
||||
f.Formatter formatter = new f.Formatter();
|
||||
f.Formatter formatter = new f.Formatter(document);
|
||||
formatter.Laboratory = importer.Laboratory;
|
||||
formatter.Elements.Add(new f.Elements.Items("Klinische Chemie: Na, K, Cl"));
|
||||
Document document = new Document();
|
||||
formatter.WriteToDocument(document);
|
||||
Assert.AreEqual("Klinische Chemie: Na: 132 mmol/l", document.Range().Text);
|
||||
formatter.Run();
|
||||
Assert.AreEqual("Klinische Chemie: Na 144 mM, K 4,3 mM\r", document.Range().Text);
|
||||
((_Document)document).Close(WdSaveOptions.wdDoNotSaveChanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user