# HG changeset patch # User IBBoard # Date 1320092589 0 # Node ID 32b3e41bc8f0377a09adc0b959429af96ceebd80 # Parent 50b8466783edd43897ef550742916d3c6f39949a 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 diff -r 50b8466783ed -r 32b3e41bc8f0 API/Factories/Requirement/Mock/MockRequirement.cs --- a/API/Factories/Requirement/Mock/MockRequirement.cs Fri Oct 28 20:52:01 2011 +0100 +++ b/API/Factories/Requirement/Mock/MockRequirement.cs Mon Oct 31 20:23:09 2011 +0000 @@ -13,6 +13,14 @@ { } + public string RequirementID + { + get + { + throw new NotImplementedException(); + } + } + public Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) { throw new NotImplementedException(); diff -r 50b8466783ed -r 32b3e41bc8f0 API/Objects/Requirement/Mock/AbstractFixedRequirement.cs --- a/API/Objects/Requirement/Mock/AbstractFixedRequirement.cs Fri Oct 28 20:52:01 2011 +0100 +++ b/API/Objects/Requirement/Mock/AbstractFixedRequirement.cs Mon Oct 31 20:23:09 2011 +0000 @@ -5,10 +5,15 @@ namespace IBBoard.WarFoundry.API.Objects.Requirement.Mock { - public class AbstractFixedRequirement : IRequirement + public abstract class AbstractFixedRequirement : IRequirement { private Validation result; + public string RequirementID + { + get { return GetType().Name; } + } + public AbstractFixedRequirement(Validation fixedResult) { result = fixedResult; diff -r 50b8466783ed -r 32b3e41bc8f0 API/Savers/IWarFoundryFileSaverTests.cs --- 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(); } } diff -r 50b8466783ed -r 32b3e41bc8f0 API/Savers/Xml/WarFoundryXmlFileSaverTests.cs --- a/API/Savers/Xml/WarFoundryXmlFileSaverTests.cs Fri Oct 28 20:52:01 2011 +0100 +++ b/API/Savers/Xml/WarFoundryXmlFileSaverTests.cs Mon Oct 31 20:23:09 2011 +0000 @@ -69,9 +69,14 @@ return StringManipulation.StringToBytes(@""); } - protected override byte[] GetGameSystemContentWithCategories () + protected override byte[] GetGameSystemContentWithCategories() { return StringManipulation.StringToBytes(@""); } + + protected override byte[] GetGameSystemContentWithStats() + { + return StringManipulation.StringToBytes(@""); + } } }