2015-06-17 18:21:10 +00:00
|
|
|
|
/* LabItemTest.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;
|
2015-06-20 14:26:10 +00:00
|
|
|
|
using zaaReloaded2.Models;
|
2015-06-17 18:21:10 +00:00
|
|
|
|
|
|
|
|
|
namespace Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
class LabItemTest
|
|
|
|
|
{
|
2015-06-20 14:26:10 +00:00
|
|
|
|
[Test]
|
|
|
|
|
[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)
|
|
|
|
|
{
|
|
|
|
|
LabItem i = new LabItem(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(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)
|
|
|
|
|
{
|
|
|
|
|
LabItem i = new LabItem(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)
|
|
|
|
|
{
|
|
|
|
|
LabItem i = new LabItem(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")]
|
|
|
|
|
public void ParseLaurisWithoutLimits(
|
|
|
|
|
string laurisString, string name, double value,
|
|
|
|
|
string unit)
|
|
|
|
|
{
|
|
|
|
|
LabItem i = new LabItem(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)
|
|
|
|
|
{
|
|
|
|
|
LabItem i = new LabItem(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 LabItem.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)
|
|
|
|
|
{
|
|
|
|
|
LabItem i = new LabItem(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 LabItem.IsNormal if no normal value known
|
|
|
|
|
}
|
2015-06-17 18:21:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|