More work on Formatter; successful tests.

This commit is contained in:
Daniel Kraus
2015-07-14 23:19:41 +02:00
parent c43b0af1e3
commit b810cc8a74
9 changed files with 117 additions and 49 deletions

View File

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

View File

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

View File

@ -1,18 +1,18 @@
# This file contains 7 time points.
# This leading text should be ignored.
# DO NOT CHANGE THE FOLLOWING TEXT, LEST THE TESTS WILL FAIL!
(06.07.2015 15:16:00)
(04.07.2015 15:16:00)
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 1300 ml; Natrium (SU): 107.8 [54 - 150] mmol/l; Natrium (SU)/die: 140.1 [40 - 220] mmol/d;
(06.07.2015 13:39:00)
(04.07.2015 13:39:00)
Urin - Klin. Chemie: Creatinin (PU): 153.7 [40 - 278] mg/dl;
(06.07.2015 12:31:00)
(04.07.2015 12:31:00)
Klinische Chemie: Natrium: 144 [135 - 145] mmol/l; Kalium: 4.3 [3.5 - 5] mmol/l; Calcium: 2.3 [2.0 - 2.7] mmol/l; Korrigiertes Calcium: 2.3 [2.0 - 2.7] mmol/l; Magnesium: 0.87 [0.7 - 1.05] mmol/l; anorg. Phosphat: 0.98 [0.87 - 1.45] mmol/l; Calcium-Phosphat-Produkt: 2.25 [<= 4.4] mmol²/l²; Glucose: 93 [74 - 106] mg/dl; glomerul. Filtrationsr. CKD-EP: 56 ml/min /1,73qm; glomerul. Filtrationsr. (MDRD): 54 ml/min /1,73qm; Creatinin: 1.52 [0 - 1.17] mg/dl; Harnstoff: 41.1 [10 - 50] mg/dl; Harnsäure: 7.7 [3.4 - 7] mg/dl; Gesamt-Bilirubin: 0.2 [0.1 - 1.2] mg/dl; GOT (ASAT): 22.2 [<= 50] U/l; GPT (ALAT): 28.0 [<= 50] U/l; GGT: 49.0 [<= 60] U/l; Alk. Phosphatase: 70 [40 - 130] U/l; Lactat Dehydrogenase: 205 [<= 250] U/l; Cholesterin: 219 [130 - 220] mg/dl; Triglyceride: 195 [74 - 172] mg/dl; LDL - Cholesterin: 141 [0 - 150] mg/dl; HDL - Cholesterin: 39 [>= 35] mg/dl; Albumin: 4.1 [3.5 - 5.5] g/dl;
Hämatologie: Leukozyten: 7.2 [5 - 10] n*1000/µl; Erythrozyten: 4.79 [4 - 6] n*10E6/µl; Hämoglobin: 14.0 [14 - 18] g/dl; Hämatokrit: 41.0 [42 - 50] %; MCV: 85.6 [82 - 94] fl; MCH (HbE): 29.2 [27 - 33] pg; MCHC: 34.1 [32 - 36] g/dl; Thrombozyten: 269 [150 - 450] n*1000/µl; Mittleres Plättchenvolumen: 10.3 [9.7 - 11.9] fl;
Urin - Klin. Chemie: Sammelzeit (U): 24 h; Sammelmenge (U): 1300 ml; Creatinin-Clearance (SU)/min: 90 [98 - 156] ml/min; Harnstoff-Clearance (SU)/min: 40 [60 - 80] ml/min; glomeruläre Filtrationsrate: 65 ml/min; Calcium (SU): 0.64 mmol/l; Calcium (SU)/die: 0.83 [2.5 - 8] mmol/d; Creatinin (SU): 151.5 mg/dl; Harnstoff (SU): 1831 [900 - 3000] mg/dl; Harnstoff (SU)/die: 23.8 [<= 35] g/d; Kalium (SU): 39.2 [20 - 80] mmol/l; Kalium (SU)/die: 50.96 [25 - 125] mmol/d; Natrium (SU): 108.1 [54 - 150] mmol/l; Natrium (SU)/die: 140.5 [40 - 220] mmol/d;
Serumproteine und Tumormarker: C-reaktives Protein: 0.71 [0 - 0.5] mg/dl;
(06.07.2015 13:29:00)
(04.07.2015 13:29:00)
Hepatitis Serologie: HBs-Antikörper: neg. ;
(06.07.2015 12:20:00)
(04.07.2015 12:20:00)
Schilddrüse: TSH: 1.30 [0.3 - 4.0] mIU/l;
Ca-Phosphat-Stoffwechsel: PTH intakt: 56.1 [12 - 65] ng/l;
(06.07.2015 10:28:00)