# HG changeset patch # User IBBoard # Date 1319831521 -3600 # Node ID 50b8466783edd43897ef550742916d3c6f39949a # Parent 01f7a713fe827888cf12b3d25527567a4f26afe4 Re #338: WarFoundry.API - Save System Data * Add test for saving categories diff -r 01f7a713fe82 -r 50b8466783ed API/Savers/IWarFoundryFileSaverTests.cs --- a/API/Savers/IWarFoundryFileSaverTests.cs Wed Oct 26 15:46:48 2011 +0100 +++ b/API/Savers/IWarFoundryFileSaverTests.cs Fri Oct 28 20:52:01 2011 +0100 @@ -367,6 +367,38 @@ } } + [Test()] + public void TestGameSystemWithCategories() + { + + string tempFile = Path.GetTempFileName(); + try + { + MockGameSystem obj = new MockGameSystem(); + Category heroCat = new Category("cat1", "Heroes"); + heroCat.MaximumPercentage = 25; + heroCat.MaximumPoints = 1000; + obj.AddCategory(heroCat); + Category warriorCat = new Category("cat2", "Warriors"); + warriorCat.MinimumPercentage = 35; + warriorCat.MinimumPoints = 500; + obj.AddCategory(warriorCat); + 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(GetGameSystemContentWithCategories())); + file.Close(); + } + finally + { + if (File.Exists(tempFile)) + { + File.Delete(tempFile); + } + } + } + protected abstract IWarFoundryFileSaver GetSaver(); protected abstract string GetEntryName(WarFoundryLoadedObject obj); @@ -390,5 +422,7 @@ protected abstract byte[] GetGameSystemContentWithPointsNameBytes(string singular, string plural); protected abstract byte[] GetGameSystemContentWithPointsAbbrevsAndNameBytes(string singular, string plural, string singularName, string pluralName); + + protected abstract byte[] GetGameSystemContentWithCategories(); } } diff -r 01f7a713fe82 -r 50b8466783ed API/Savers/Xml/WarFoundryXmlFileSaverTests.cs --- a/API/Savers/Xml/WarFoundryXmlFileSaverTests.cs Wed Oct 26 15:46:48 2011 +0100 +++ b/API/Savers/Xml/WarFoundryXmlFileSaverTests.cs Fri Oct 28 20:52:01 2011 +0100 @@ -66,7 +66,12 @@ protected override byte[] GetGameSystemContentWithPointsAbbrevsAndNameBytes(string singular, string plural, string singularName, string pluralName) { - return StringManipulation.StringToBytes(@""); + return StringManipulation.StringToBytes(@""); + } + + protected override byte[] GetGameSystemContentWithCategories () + { + return StringManipulation.StringToBytes(@""); } } }