2015-07-13 21:57:35 +00:00
|
|
|
|
/* ItemsTest.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 Microsoft.Office.Interop.Word;
|
|
|
|
|
using zaaReloaded2.LabModel;
|
|
|
|
|
using zaaReloaded2.Formatter;
|
2015-07-15 23:49:17 +00:00
|
|
|
|
using zaa = zaaReloaded2.Controller.Elements;
|
2015-07-13 21:57:35 +00:00
|
|
|
|
|
2015-07-16 22:23:06 +00:00
|
|
|
|
namespace Tests.Controller.Elements
|
2015-07-13 21:57:35 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
class ItemsTest
|
|
|
|
|
{
|
2015-07-25 12:33:48 +00:00
|
|
|
|
Document _document;
|
2015-07-14 21:19:41 +00:00
|
|
|
|
zaaReloaded2.Formatter.Formatter _formatter;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUp()
|
|
|
|
|
{
|
2015-07-25 12:33:48 +00:00
|
|
|
|
_document = new Document();
|
|
|
|
|
_formatter = new zaaReloaded2.Formatter.Formatter(_document);
|
2015-07-19 06:28:40 +00:00
|
|
|
|
_formatter.Settings.ReferenceStyle = ReferenceStyle.IfAbnormal;
|
2015-07-14 21:19:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TearDown]
|
|
|
|
|
public void TearDown()
|
|
|
|
|
{
|
2015-07-25 12:33:48 +00:00
|
|
|
|
((_Document)_document).Close(WdSaveOptions.wdDoNotSaveChanges);
|
2015-07-14 21:19:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-13 21:57:35 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void ItemsTestWithoutCaption()
|
|
|
|
|
{
|
2015-07-14 21:19:41 +00:00
|
|
|
|
Laboratory lab = new Laboratory();
|
2015-07-13 21:57:35 +00:00
|
|
|
|
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.
|
2015-07-14 21:19:41 +00:00
|
|
|
|
lab.AddTimePoint(tp);
|
|
|
|
|
|
|
|
|
|
_formatter.Laboratory = lab;
|
2015-07-15 23:49:17 +00:00
|
|
|
|
_formatter.Settings.Elements.Add(new zaa.Items("Na, K, Cl"));
|
2015-07-14 21:19:41 +00:00
|
|
|
|
_formatter.Run();
|
2015-07-25 12:33:48 +00:00
|
|
|
|
Assert.AreEqual("Na 133, K 6 (5)\r", _document.Range().Text);
|
2015-07-13 21:57:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ItemsTestWithCaption()
|
|
|
|
|
{
|
2015-07-14 21:19:41 +00:00
|
|
|
|
Laboratory lab = new Laboratory();
|
2015-07-13 21:57:35 +00:00
|
|
|
|
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.
|
2015-07-14 21:19:41 +00:00
|
|
|
|
lab.AddTimePoint(tp);
|
|
|
|
|
|
|
|
|
|
_formatter.Laboratory = lab;
|
2015-07-15 23:49:17 +00:00
|
|
|
|
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl"));
|
2015-07-14 21:19:41 +00:00
|
|
|
|
_formatter.Run();
|
2015-07-25 12:33:48 +00:00
|
|
|
|
Assert.AreEqual("Klinische Chemie: Na 133, K 6 (5)\r", _document.Range().Text);
|
2015-07-13 21:57:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ItemsTestWithCaptionButNoItems()
|
|
|
|
|
{
|
2015-07-14 21:19:41 +00:00
|
|
|
|
Laboratory lab = new Laboratory();
|
2015-07-13 21:57:35 +00:00
|
|
|
|
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.
|
2015-07-14 21:19:41 +00:00
|
|
|
|
lab.AddTimePoint(tp);
|
|
|
|
|
|
|
|
|
|
_formatter.Laboratory = lab;
|
2015-07-15 23:49:17 +00:00
|
|
|
|
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: this, does, not, exist"));
|
2015-07-14 21:19:41 +00:00
|
|
|
|
_formatter.Run();
|
2015-07-25 12:33:48 +00:00
|
|
|
|
Assert.AreEqual("\r", _document.Range().Text);
|
2015-07-13 21:57:35 +00:00
|
|
|
|
}
|
2015-07-19 06:28:40 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GenericItemsWildcard()
|
|
|
|
|
{
|
|
|
|
|
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", ""));
|
|
|
|
|
tp.AddItem(new LabItem("Cl", "110", ""));
|
|
|
|
|
lab.AddTimePoint(tp);
|
|
|
|
|
|
|
|
|
|
_formatter.Settings.ReferenceStyle = ReferenceStyle.Never;
|
|
|
|
|
_formatter.Laboratory = lab;
|
|
|
|
|
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, *"));
|
|
|
|
|
_formatter.Run();
|
|
|
|
|
Assert.AreEqual("Klinische Chemie: Na 133, Cl 110, K 6\r",
|
2015-07-25 12:33:48 +00:00
|
|
|
|
_document.Range().Text);
|
2015-07-19 06:28:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void MaterialWildcard()
|
|
|
|
|
{
|
|
|
|
|
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("U-Na", "99", ""));
|
|
|
|
|
tp.AddItem(new LabItem("Cl", "110", ""));
|
|
|
|
|
tp.AddItem(new LabItem("SU-Protein", "2.8", ""));
|
|
|
|
|
lab.AddTimePoint(tp);
|
|
|
|
|
|
|
|
|
|
_formatter.Settings.ReferenceStyle = ReferenceStyle.Never;
|
|
|
|
|
_formatter.Laboratory = lab;
|
|
|
|
|
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*"));
|
|
|
|
|
_formatter.Run();
|
|
|
|
|
Assert.AreEqual("Klinische Chemie: Na 133, SU-Protein 2,8\r",
|
2015-07-25 12:33:48 +00:00
|
|
|
|
_document.Range().Text);
|
2015-07-19 06:28:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void MaterialAndGenericWildcard()
|
|
|
|
|
{
|
|
|
|
|
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("U-Na", "99", ""));
|
|
|
|
|
tp.AddItem(new LabItem("Cl", "110", ""));
|
|
|
|
|
tp.AddItem(new LabItem("SU-Protein", "2.8", ""));
|
|
|
|
|
lab.AddTimePoint(tp);
|
|
|
|
|
|
|
|
|
|
_formatter.Settings.ReferenceStyle = ReferenceStyle.Never;
|
|
|
|
|
_formatter.Laboratory = lab;
|
|
|
|
|
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*, *"));
|
|
|
|
|
_formatter.Run();
|
|
|
|
|
Assert.AreEqual("Klinische Chemie: Na 133, SU-Protein 2,8, Cl 110, U-Na 99\r",
|
2015-07-25 12:33:48 +00:00
|
|
|
|
_document.Range().Text);
|
2015-07-19 06:28:40 +00:00
|
|
|
|
}
|
2015-07-13 21:57:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|