Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 100:5addcb8f7766
Re #324: Add saving of Race and System data to files
* Add unit tests for multiple files in one zip
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 12 Mar 2011 19:54:07 +0000 |
parents | dd384f35a96f |
children | 08fd75eafb67 |
files | API/Savers/IWarFoundryFileSaverTests.cs |
diffstat | 1 files changed, 48 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Savers/IWarFoundryFileSaverTests.cs Wed Mar 09 20:55:35 2011 +0000 +++ b/API/Savers/IWarFoundryFileSaverTests.cs Sat Mar 12 19:54:07 2011 +0000 @@ -143,6 +143,54 @@ } } } + + [Test()] + public void TestSaverCreatesTwoEntriesForOneSystemOneArmy() + { + string tempFile = Path.GetTempFileName(); + try + { + GetSaver().Save(tempFile, new MockGameSystem(), MockArmy.GetMockArmy()); + ZipFile file = new ZipFile(tempFile); + Assert.That(file.Count, Is.EqualTo(2)); + file.Close(); + } + finally + { + if (File.Exists(tempFile)) + { + File.Delete(tempFile); + } + } + } + + [Test()] + public void TestSaverCreatesTwoEntriesWithCorrectContentForOneSystemOneArmy() + { + //This doesn't make much sense (system and army in one file) but at the time of writing then Race isn't implemented + string tempFile = Path.GetTempFileName(); + try + { + MockGameSystem system = new MockGameSystem(); + MockArmy army = MockArmy.GetMockArmy(); + GetSaver().Save(tempFile, system, army); + ZipFile file = new ZipFile(tempFile); + ZipEntry zipEntry = file.GetEntry(GetEntryName(system)); + Stream stream = file.GetInputStream(zipEntry); + Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentBytes())); + zipEntry = file.GetEntry(GetEntryName(army)); + stream = file.GetInputStream(zipEntry); + Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetArmyContentBytes())); + file.Close(); + } + finally + { + if (File.Exists(tempFile)) + { + File.Delete(tempFile); + } + } + } [Test()] public void TestFileExtensionsAreCorrectForType()