7997e307fa
- VERBESSERT: Extreme Werte (mit "<" oder ">") wurden nicht sehr schön formatiert.
164 lines
7.8 KiB
C#
Executable File
164 lines
7.8 KiB
C#
Executable File
/* LaurisItemTest.cs
|
||
* 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;
|
||
using zaaReloaded2.LabModel;
|
||
using zaaReloaded2.Importer.ZaaImporter;
|
||
|
||
namespace Tests.Importer.ZaaImporter
|
||
{
|
||
[TestFixture]
|
||
class LaurisItemTest
|
||
{
|
||
[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)]
|
||
[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)
|
||
{
|
||
LaurisItem i = new LaurisItem(laurisString);
|
||
Assert.AreEqual(name, i.Name, "Name");
|
||
Assert.AreEqual(unit, i.Unit, "Unit");
|
||
Assert.IsFalse(i.IsExtreme, "IsExtreme");
|
||
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");
|
||
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)
|
||
{
|
||
LaurisItem i = new LaurisItem(laurisString);
|
||
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)
|
||
{
|
||
LaurisItem i = new LaurisItem(laurisString);
|
||
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")]
|
||
public void ParseLaurisWithoutLimits(
|
||
string laurisString, string name, double value,
|
||
string unit)
|
||
{
|
||
LaurisItem i = new LaurisItem(laurisString);
|
||
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)
|
||
{
|
||
LaurisItem i = new LaurisItem(laurisString);
|
||
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");
|
||
// TODO: Define the behavior of LaurisItem.IsNormal if no normal value known
|
||
}
|
||
|
||
[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)
|
||
{
|
||
LaurisItem i = new LaurisItem(laurisString);
|
||
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");
|
||
// TODO: Define the behavior of LaurisItem.IsNormal if no normal value known
|
||
}
|
||
|
||
[TestCase("Albumin (SU)/die: 149.9 [<= 30] mg/d; ", Material.SU)]
|
||
[TestCase("Gesamt-Eiweiss/Creatinin (PU): 281 [<= 70] mg/g Crea;", Material.U)]
|
||
[TestCase("Cystatin C (N Latex): 2.37 [0.57 - 0.96] mg/l; ", Material.B)]
|
||
public void ParseLaurisMaterial(string laurisString, Material expectedMaterial)
|
||
{
|
||
LaurisItem i = new LaurisItem(laurisString);
|
||
Assert.AreEqual(expectedMaterial, i.Material);
|
||
}
|
||
}
|
||
}
|