# HG changeset patch
# User dkulinski
# Date 1315524851 21600
# Node ID e29650db551fa056128e08bc53fab0024d73dea4
# Parent 23e7f51386fd31f270c588f72648ba1944b0d883
XSL Test case
diff -r 23e7f51386fd -r e29650db551f API/Exporters/XmlSaveTest.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/API/Exporters/XmlSaveTest.cs Thu Sep 08 17:34:11 2011 -0600
@@ -0,0 +1,67 @@
+// This file (UnitTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard
+//
+// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
+
+using System;
+using System.Xml;
+using System.Xml.Xsl;
+using NUnit.Framework;
+using XmlUnit;
+using IBBoard.WarFoundry.API.Objects.Mock;
+using IBBoard.WarFoundry.API.Util;
+using IBBoard.WarFoundry.API.Exporters;
+using IBBoard.Limits;
+
+namespace IBBoard.WarFoundry.API.Objects
+{
+ [TestFixture()]
+ public class XmlSaveTest
+ {
+ Army mockArmy;
+ string outputFile = "test_output.xml";
+ string goldFile = "testdata\\xml_output.xml";
+
+ string xslt = "";
+ string goldOutput = "Mock Army";
+ [TestFixtureSetUp()]
+ public void XmlTestSetup()
+ {
+ mockArmy = MockArmy.GetMockArmy();
+ UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(5);
+ UnitType unitType = equip.EquipmentForUnit;
+ Unit unit = new Unit("unit", "Test Unit", 10, unitType, new MockArmyCategory(unitType.MainCategory));
+ mockArmy.AddUnit(unit);
+
+ WarFoundryXmlWithXslExporter.GetDefault().ExportArmy(mockArmy, outputFile);
+ }
+
+ // Basic validation of XML output
+ [Test()]
+ public void TestXmlOutputValid()
+ {
+ XmlInput dirty = new XmlInput(new XmlTextReader(outputFile));
+ XmlAssertion.AssertXmlValid(dirty);
+ }
+
+ // Basic save test and comparison
+ [Test()]
+ public void TestBasicXmlOutput()
+ {
+ XmlInput dirty = new XmlInput(new XmlTextReader(outputFile));
+ XmlInput gold = new XmlInput(new XmlTextReader(goldFile));
+
+ XmlAssertion.AssertXmlIdentical(gold, dirty);
+
+ }
+ // Simple transform test
+ [Test()]
+ public void TestTransformedOutput()
+ {
+ XmlInput xmlIn = new XmlInput(new XmlTextReader(outputFile));
+ XmlInput xslIn = new XmlInput(new XmlTextReader(new System.IO.StringReader(xslt)));
+ XmlInput outputCompare = new XmlInput(new XmlTextReader(new System.IO.StringReader(goldOutput)));
+
+ XmlAssertion.AssertXslTransformResults(xslIn, xmlIn, outputCompare);
+ }
+ }
+}
diff -r 23e7f51386fd -r e29650db551f IBBoard.WarFoundry.API.Tests.csproj
--- a/IBBoard.WarFoundry.API.Tests.csproj Sun Aug 14 01:19:12 2011 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj Thu Sep 08 17:34:11 2011 -0600
@@ -1,4 +1,4 @@
-
+
Debug
@@ -58,6 +58,7 @@
-->
+
@@ -183,6 +184,7 @@
PreserveNewest
+ Designer
PreserveNewest
@@ -320,6 +322,10 @@
{C52AFD32-B869-4E14-AACE-2846AD2CC742}
IBBoard.NUnit
+
+ {E66FAEFC-4599-4AAB-A57F-0BB2554FA5B6}
+ Xmlunit
+
@@ -366,4 +372,11 @@
+
+
+
+ PreserveNewest
+ Designer
+
+
\ No newline at end of file
diff -r 23e7f51386fd -r e29650db551f testdata/xml_output.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/testdata/xml_output.xml Thu Sep 08 17:34:11 2011 -0600
@@ -0,0 +1,14 @@
+
+
+ Mock Race
+ Mock Army
+ 2000
+ 0
+
+
+
+
+
+
+
+
\ No newline at end of file