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 diff
     1.1 --- a/API/Savers/IWarFoundryFileSaverTests.cs	Wed Mar 09 20:55:35 2011 +0000
     1.2 +++ b/API/Savers/IWarFoundryFileSaverTests.cs	Sat Mar 12 19:54:07 2011 +0000
     1.3 @@ -143,6 +143,54 @@
     1.4  				}
     1.5  			}
     1.6  		}
     1.7 +
     1.8 +		[Test()]
     1.9 +		public void TestSaverCreatesTwoEntriesForOneSystemOneArmy()
    1.10 +		{
    1.11 +			string tempFile = Path.GetTempFileName();
    1.12 +			try
    1.13 +			{
    1.14 +				GetSaver().Save(tempFile, new MockGameSystem(), MockArmy.GetMockArmy());
    1.15 +				ZipFile file = new ZipFile(tempFile);
    1.16 +				Assert.That(file.Count, Is.EqualTo(2));
    1.17 +				file.Close();
    1.18 +			}
    1.19 +			finally
    1.20 +			{
    1.21 +				if (File.Exists(tempFile))
    1.22 +				{
    1.23 +					File.Delete(tempFile);
    1.24 +				}
    1.25 +			}
    1.26 +		}
    1.27 +
    1.28 +		[Test()]
    1.29 +		public void TestSaverCreatesTwoEntriesWithCorrectContentForOneSystemOneArmy()
    1.30 +		{
    1.31 +			//This doesn't make much sense (system and army in one file) but at the time of writing then Race isn't implemented
    1.32 +			string tempFile = Path.GetTempFileName();
    1.33 +			try
    1.34 +			{
    1.35 +				MockGameSystem system = new MockGameSystem();
    1.36 +				MockArmy army = MockArmy.GetMockArmy();
    1.37 +				GetSaver().Save(tempFile, system, army);
    1.38 +				ZipFile file = new ZipFile(tempFile);
    1.39 +				ZipEntry zipEntry = file.GetEntry(GetEntryName(system));
    1.40 +				Stream stream = file.GetInputStream(zipEntry);
    1.41 +				Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentBytes()));
    1.42 +				zipEntry = file.GetEntry(GetEntryName(army));
    1.43 +				stream = file.GetInputStream(zipEntry);
    1.44 +				Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetArmyContentBytes()));
    1.45 +				file.Close();
    1.46 +			}
    1.47 +			finally
    1.48 +			{
    1.49 +				if (File.Exists(tempFile))
    1.50 +				{
    1.51 +					File.Delete(tempFile);
    1.52 +				}
    1.53 +			}
    1.54 +		}
    1.55  		
    1.56  		[Test()]
    1.57  		public void TestFileExtensionsAreCorrectForType()