Implement Lauris parsing in LabItem.
This commit is contained in:
@ -20,11 +20,111 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using zaaReloaded2.Models;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
[TestFixture]
|
||||
class LabItemTest
|
||||
{
|
||||
[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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,12 @@
|
||||
<None Include="packages.config" />
|
||||
<None Include="Tests.licenseheader" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\zaaReloaded2\zaaReloaded2.csproj">
|
||||
<Project>{0478f1b0-17f2-4151-8f93-1cb6eb9732c5}</Project>
|
||||
<Name>zaaReloaded2</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user