Implement DocumentWriter, control elements, and tests.

This commit is contained in:
Daniel Kraus
2015-07-25 14:33:48 +02:00
parent 659713abe3
commit 9df937138d
22 changed files with 722 additions and 151 deletions

View File

@ -30,19 +30,21 @@ namespace Tests.Controller.Elements
[TestFixture]
class ItemsTest
{
Document _document;
zaaReloaded2.Formatter.Formatter _formatter;
[SetUp]
public void SetUp()
{
_formatter = new zaaReloaded2.Formatter.Formatter(new Document());
_document = new Document();
_formatter = new zaaReloaded2.Formatter.Formatter(_document);
_formatter.Settings.ReferenceStyle = ReferenceStyle.IfAbnormal;
}
[TearDown]
public void TearDown()
{
((_Document)_formatter.Document).Close(WdSaveOptions.wdDoNotSaveChanges);
((_Document)_document).Close(WdSaveOptions.wdDoNotSaveChanges);
}
[Test]
@ -57,10 +59,9 @@ namespace Tests.Controller.Elements
lab.AddTimePoint(tp);
_formatter.Laboratory = lab;
_formatter.SelectFirstDay();
_formatter.Settings.Elements.Add(new zaa.Items("Na, K, Cl"));
_formatter.Run();
Assert.AreEqual("Na 133, K 6 (5)\r", _formatter.Document.Range().Text);
Assert.AreEqual("Na 133, K 6 (5)\r", _document.Range().Text);
}
[Test]
@ -75,10 +76,9 @@ namespace Tests.Controller.Elements
lab.AddTimePoint(tp);
_formatter.Laboratory = lab;
_formatter.SelectFirstDay();
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl"));
_formatter.Run();
Assert.AreEqual("Klinische Chemie: Na 133, K 6 (5)\r", _formatter.Document.Range().Text);
Assert.AreEqual("Klinische Chemie: Na 133, K 6 (5)\r", _document.Range().Text);
}
[Test]
@ -93,10 +93,9 @@ namespace Tests.Controller.Elements
lab.AddTimePoint(tp);
_formatter.Laboratory = lab;
_formatter.SelectFirstDay();
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: this, does, not, exist"));
_formatter.Run();
Assert.AreEqual("\r", _formatter.Document.Range().Text);
Assert.AreEqual("\r", _document.Range().Text);
}
[Test]
@ -112,11 +111,10 @@ namespace Tests.Controller.Elements
_formatter.Settings.ReferenceStyle = ReferenceStyle.Never;
_formatter.Laboratory = lab;
_formatter.SelectFirstDay();
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, *"));
_formatter.Run();
Assert.AreEqual("Klinische Chemie: Na 133, Cl 110, K 6\r",
_formatter.Document.Range().Text);
_document.Range().Text);
}
[Test]
@ -133,11 +131,10 @@ namespace Tests.Controller.Elements
_formatter.Settings.ReferenceStyle = ReferenceStyle.Never;
_formatter.Laboratory = lab;
_formatter.SelectFirstDay();
_formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*"));
_formatter.Run();
Assert.AreEqual("Klinische Chemie: Na 133, SU-Protein 2,8\r",
_formatter.Document.Range().Text);
_document.Range().Text);
}
[Test]
@ -154,11 +151,10 @@ namespace Tests.Controller.Elements
_formatter.Settings.ReferenceStyle = ReferenceStyle.Never;
_formatter.Laboratory = lab;
_formatter.SelectFirstDay();
_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",
_formatter.Document.Range().Text);
_document.Range().Text);
}
}
}

View File

@ -1,45 +0,0 @@
/* SelectFirstDayTest.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 f = zaaReloaded2.Formatter;
using zaaReloaded2.Importer.ZaaImporter;
using zaaReloaded2.Controller.Elements;
namespace Tests.Controller.Elements
{
[TestFixture]
class SelectFirstDayTest
{
[Test]
public void SelectFirstDay()
{
SelectFirstDay element = new SelectFirstDay();
ZaaImporter importer = TestHelpers.ZaaImporterFromResource();
f.Formatter formatter = new f.Formatter();
formatter.Laboratory = importer.Laboratory;
element.Run(formatter);
Assert.AreEqual(5, formatter.WorkingTimePoints.Count);
DateTime firstDay = new DateTime(2015, 07, 04);
Assert.AreEqual(firstDay.Date, formatter.WorkingTimePoints.First().Key.Date);
}
}
}

View File

@ -1,49 +0,0 @@
/* SelectFirstDayTest - Copy.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 f = zaaReloaded2.Formatter;
using zaaReloaded2.Importer.ZaaImporter;
using zaaReloaded2.Controller.Elements;
namespace Tests.Controller.Elements
{
[TestFixture]
class SelectLastDayTest
{
[Test]
public void SelectLastDay()
{
SelectLastDay element = new SelectLastDay();
ZaaImporter importer = TestHelpers.ZaaImporterFromResource();
f.Formatter formatter = new f.Formatter();
formatter.Laboratory = importer.Laboratory;
element.Run(formatter);
// There are two time points of 6-July-2015 in the demo output file,
// but since they have the exact same time stamps, they are merged
// into one!
Assert.AreEqual(1, formatter.WorkingTimePoints.Count);
DateTime firstDay = new DateTime(2015, 07, 06);
Assert.AreEqual(firstDay.Date, formatter.WorkingTimePoints.First().Key.Date);
}
}
}