zaaReloaded2/Tests/Importer/ZaaImporter/LaurisItemTest.cs

164 lines
7.8 KiB
C#
Raw Normal View History

2015-07-06 13:48:43 +00:00
/* LaurisItemTest.cs
2015-06-17 18:21:10 +00:00
* part of zaaReloaded2
*
* Copyright 2015 Daniel Kraus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
2015-07-06 13:48:43 +00:00
using zaaReloaded2.LabModel;
using zaaReloaded2.Importer.ZaaImporter;
2015-06-17 18:21:10 +00:00
2015-07-06 13:48:43 +00:00
namespace Tests.Importer.ZaaImporter
2015-06-17 18:21:10 +00:00
{
[TestFixture]
2015-07-06 13:48:43 +00:00
class LaurisItemTest
2015-06-17 18:21:10 +00:00
{
2015-06-20 14:26:10 +00:00
[Test]
[TestCase("BE: 5.2 [-2 - 2] mmol/l", "BE", 5.2, "mmol/l", -2, 2, false)]
[TestCase("Comma: 5,2 [-2,1 - 2,3] mmol/l", "Comma", 5.2, "mmol/l", -2.1, 2.3, false)]
2015-06-20 14:26:10 +00:00
[TestCase("Natrium: 139 [135 - 145] mmol/l", "Natrium", 139, "mmol/l", 135, 145, true)]
[TestCase("Kalium: 5.2 [3.5 - 5] mmol/l", "Kalium", 5.2, "mmol/l", 3.5, 5, false)]
public void ParseLaurisWithBothLimits(
string laurisString, string name, double value,
string unit, double lowerLimit, double upperLimit, bool isNormal)
{
2015-07-06 13:48:43 +00:00
LaurisItem i = new LaurisItem(laurisString);
2015-06-20 14:26:10 +00:00
Assert.AreEqual(name, i.Name, "Name");
Assert.AreEqual(unit, i.Unit, "Unit");
Assert.IsFalse(i.IsExtreme, "IsExtreme");
2015-06-20 14:26:10 +00:00
Assert.IsTrue(i.IsNumerical, "IsNumerical");
Assert.AreEqual(value, i.NumericalValue, "NumericalValue");
Assert.AreEqual(lowerLimit, i.LowerLimit, "Lower limit");
Assert.AreEqual(upperLimit, i.UpperLimit, "Upper limit");
Assert.AreEqual(isNormal, i.IsNormal, "IsNormal");
Assert.IsTrue(i.HasLimits, "HasLimits");
Assert.IsTrue(i.HasLowerLimit, "HasLowerLimit");
Assert.IsTrue(i.HasUpperLimit, "HasUpperLimit");
}
[TestCase("Folsäure: > 20 [2.0 - 9.1] ng/ml; ", "Folsäure", "> 20", "ng/ml", 2, 9.1, false)]
public void ParseLaurisWithGreaterOrLowerValue(
string laurisString, string name, string value,
string unit, double lowerLimit, double upperLimit, bool isNormal)
{
LaurisItem i = new LaurisItem(laurisString);
Assert.AreEqual(name, i.Name, "Name");
Assert.AreEqual(unit, i.Unit, "Unit");
Assert.IsTrue(i.IsExtreme, "IsExtreme");
Assert.IsFalse(i.IsNumerical, "IsNumerical");
Assert.AreEqual(value, i.Value, "Value");
Assert.AreEqual(lowerLimit, i.LowerLimit, "Lower limit");
2015-06-20 14:26:10 +00:00
Assert.AreEqual(upperLimit, i.UpperLimit, "Upper limit");
Assert.AreEqual(isNormal, i.IsNormal, "IsNormal");
Assert.IsTrue(i.HasLimits, "HasLimits");
Assert.IsTrue(i.HasLowerLimit, "HasLowerLimit");
Assert.IsTrue(i.HasUpperLimit, "HasUpperLimit");
}
[TestCase("HDL - Cholesterin: 45 [>= 35] mg/dl", "HDL - Cholesterin", 45, "mg/dl", 35, true)]
public void ParseLaurisWithLowerLimit(
string laurisString, string name, double value,
string unit, double lowerLimit, bool isNormal)
{
2015-07-06 13:48:43 +00:00
LaurisItem i = new LaurisItem(laurisString);
2015-06-20 14:26:10 +00:00
Assert.AreEqual(name, i.Name, "Name");
Assert.AreEqual(unit, i.Unit, "Unit");
Assert.IsTrue(i.IsNumerical, "IsNumerical");
Assert.AreEqual(value, i.NumericalValue, "NumericalValue");
Assert.AreEqual(lowerLimit, i.LowerLimit, "Lower limit");
Assert.AreEqual(isNormal, i.IsNormal, "IsNormal");
Assert.IsTrue(i.HasLimits, "HasLimits");
Assert.IsTrue(i.HasLowerLimit, "HasLowerLimit");
Assert.IsFalse(i.HasUpperLimit, "HasUpperLimit");
}
[TestCase("GOT (ASAT): 303.0 [<= 50] U/l; ", "GOT (ASAT)", 303, "U/l", 50, false)]
public void ParseLaurisWithUpperLimit(
string laurisString, string name, double value,
string unit, double upperLimit, bool isNormal)
{
2015-07-06 13:48:43 +00:00
LaurisItem i = new LaurisItem(laurisString);
2015-06-20 14:26:10 +00:00
Assert.AreEqual(name, i.Name, "Name");
Assert.AreEqual(unit, i.Unit, "Unit");
Assert.IsTrue(i.IsNumerical, "IsNumerical");
Assert.AreEqual(value, i.NumericalValue, "NumericalValue");
Assert.AreEqual(upperLimit, i.UpperLimit, "Upper limit");
Assert.AreEqual(isNormal, i.IsNormal, "IsNormal");
Assert.IsTrue(i.HasLimits, "HasLimits");
Assert.IsFalse(i.HasLowerLimit, "HasLowerLimit");
Assert.IsTrue(i.HasUpperLimit, "HasUpperLimit");
}
[TestCase("Niedermol. Heparin (Anti-Xa): 0.99 U/ml;", "Niedermol. Heparin (Anti-Xa)", 0.99, "U/ml")]
[TestCase("glomerul. Filtrationsr. CKD-EP: 42 ml/min /1,73qm;", "glomerul. Filtrationsr. CKD-EP", 42, "ml/min /1,73qm")]
[TestCase("NT-proBNP: 598 [s. Bem.] pg/ml;", "NT-proBNP", 598, "pg/ml")]
2015-06-20 14:26:10 +00:00
public void ParseLaurisWithoutLimits(
string laurisString, string name, double value,
string unit)
{
2015-07-06 13:48:43 +00:00
LaurisItem i = new LaurisItem(laurisString);
2015-06-20 14:26:10 +00:00
Assert.AreEqual(name, i.Name, "Name");
Assert.AreEqual(unit, i.Unit, "Unit");
Assert.IsTrue(i.IsNumerical, "IsNumerical");
Assert.AreEqual(value, i.NumericalValue, "NumericalValue");
Assert.IsFalse(i.HasLimits, "HasLimits");
Assert.IsFalse(i.HasLowerLimit, "HasLowerLimit");
Assert.IsFalse(i.HasUpperLimit, "HasUpperLimit");
}
[TestCase("HBs-Antigen: neg. ;", "HBs-Antigen", "neg.")]
public void ParseLaurisNonNumericNoNormal(
string laurisString, string name, string value)
{
2015-07-06 13:48:43 +00:00
LaurisItem i = new LaurisItem(laurisString);
2015-06-20 14:26:10 +00:00
Assert.AreEqual(name, i.Name, "Name");
Assert.AreEqual(value, i.Value, "Value");
Assert.IsTrue(String.IsNullOrEmpty(i.Unit), "Unit should be a null string");
Assert.IsFalse(i.HasLimits, "HasLimits");
Assert.IsFalse(i.HasLowerLimit, "HasLowerLimit");
Assert.IsFalse(i.HasUpperLimit, "HasUpperLimit");
2015-07-06 13:48:43 +00:00
// TODO: Define the behavior of LaurisItem.IsNormal if no normal value known
2015-06-20 14:26:10 +00:00
}
[TestCase("Erythrozyten (U): + [negativ]", "Erythrozyten (U)", "+", "negativ", false)]
[TestCase("Bilirubin (U): negativ [negativ]", "Bilirubin (U)", "negativ", "negativ", true)]
public void ParseLaurisNonNumericWithNormal(
string laurisString, string name, string value, string normal, bool isNormal)
{
2015-07-06 13:48:43 +00:00
LaurisItem i = new LaurisItem(laurisString);
2015-06-20 14:26:10 +00:00
Assert.AreEqual(name, i.Name, "Name");
Assert.AreEqual(value, i.Value, "Value");
Assert.AreEqual(normal, i.Normal, "Normal");
Assert.AreEqual(isNormal, i.IsNormal, "IsNormal");
Assert.IsFalse(i.HasLimits, "HasLimits");
Assert.IsFalse(i.HasLowerLimit, "HasLowerLimit");
Assert.IsFalse(i.HasUpperLimit, "HasUpperLimit");
2015-07-06 13:48:43 +00:00
// TODO: Define the behavior of LaurisItem.IsNormal if no normal value known
2015-06-20 14:26:10 +00:00
}
2015-06-29 19:50:27 +00:00
[TestCase("Albumin (SU)/die: 149.9 [<= 30] mg/d; ", Material.SU)]
[TestCase("Gesamt-Eiweiss/Creatinin (PU): 281 [<= 70] mg/g Crea;", Material.U)]
2016-10-03 14:09:43 +00:00
[TestCase("Cystatin C (N Latex): 2.37 [0.57 - 0.96] mg/l; ", Material.S)]
2015-06-29 19:50:27 +00:00
public void ParseLaurisMaterial(string laurisString, Material expectedMaterial)
{
2015-07-06 13:48:43 +00:00
LaurisItem i = new LaurisItem(laurisString);
2015-06-29 19:50:27 +00:00
Assert.AreEqual(expectedMaterial, i.Material);
}
2015-06-17 18:21:10 +00:00
}
}