Mercurial > repos > IBBoard.WarFoundry.API.Tests
diff API/Savers/IWarFoundryFileSaverTests.cs @ 178:50b8466783ed
Re #338: WarFoundry.API - Save System Data
* Add test for saving categories
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 28 Oct 2011 20:52:01 +0100 |
parents | 01f7a713fe82 |
children | 32b3e41bc8f0 |
line wrap: on
line diff
--- 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(); } }