diff API/Savers/IWarFoundryFileSaverTests.cs @ 179:32b3e41bc8f0

Fixes #338: WarFoundry.API - Save System Data * Add final test to cover all of system data * Add "expected" data to XML test to check conformance
author IBBoard <dev@ibboard.co.uk>
date Mon, 31 Oct 2011 20:23:09 +0000
parents 50b8466783ed
children
line wrap: on
line diff
--- a/API/Savers/IWarFoundryFileSaverTests.cs	Fri Oct 28 20:52:01 2011 +0100
+++ b/API/Savers/IWarFoundryFileSaverTests.cs	Mon Oct 31 20:23:09 2011 +0000
@@ -370,7 +370,6 @@
 		[Test()]
 		public void TestGameSystemWithCategories()
 		{
-
 			string tempFile = Path.GetTempFileName();
 			try
 			{
@@ -399,6 +398,37 @@
 			}
 		}
 
+		[Test()]
+		public void TestGameSystemWithStatLines()
+		{
+			string tempFile = Path.GetTempFileName();
+			try
+			{
+				MockGameSystem obj = new MockGameSystem();
+				//MockGameSystem already has a stat line, so add one more
+				SystemStats systemStats = new SystemStats("stats");
+				systemStats.AddStatSlot("M");
+				systemStats.AddStatSlot("S");
+				systemStats.AddStatSlot("T");
+				systemStats.AddStatSlot("W");
+				obj.AddSystemStats(systemStats);
+				obj.StandardSystemStatsID = "stats";
+				GetSaver().Save(tempFile, obj);
+				ZipFile file = new ZipFile(tempFile);
+				ZipEntry zipEntry = file.GetEntry(GetEntryName(obj));
+				Stream stream = file.GetInputStream(zipEntry);
+				Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentWithStats()));
+				file.Close();
+			}
+			finally
+			{
+				if (File.Exists(tempFile))
+				{
+					File.Delete(tempFile);
+				}
+			}
+		}
+
 		protected abstract IWarFoundryFileSaver GetSaver();
 
 		protected abstract string GetEntryName(WarFoundryLoadedObject obj);
@@ -424,5 +454,7 @@
 		protected abstract byte[] GetGameSystemContentWithPointsAbbrevsAndNameBytes(string singular, string plural, string singularName, string pluralName);
 
 		protected abstract byte[] GetGameSystemContentWithCategories();
+
+		protected abstract byte[] GetGameSystemContentWithStats();
 	}
 }