Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
diff API/Savers/IWarFoundryFileSaverTests.cs @ 172:c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
* Remove MockArmyCategory as MockArmy change would make it do nothing special
* Close streams as well as files to fix Windows unit test errors
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 24 Sep 2011 11:46:20 +0100 |
parents | 08fd75eafb67 |
children | 9a1763af5fd2 |
line wrap: on
line diff
--- a/API/Savers/IWarFoundryFileSaverTests.cs Tue Sep 13 20:49:06 2011 +0100 +++ b/API/Savers/IWarFoundryFileSaverTests.cs Sat Sep 24 11:46:20 2011 +0100 @@ -128,12 +128,13 @@ string tempFile = Path.GetTempFileName(); try { - MockArmy obj = MockArmy.GetMockArmy(); + MockArmy obj = new MockArmy(); 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(GetArmyContentBytes())); + Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetArmyContentBytes())); + stream.Close(); file.Close(); } finally @@ -151,7 +152,7 @@ string tempFile = Path.GetTempFileName(); try { - GetSaver().Save(tempFile, new MockGameSystem(), MockArmy.GetMockArmy()); + GetSaver().Save(tempFile, new MockGameSystem(), new MockArmy()); ZipFile file = new ZipFile(tempFile); Assert.That(file.Count, Is.EqualTo(2)); file.Close(); @@ -173,7 +174,7 @@ try { MockGameSystem system = new MockGameSystem(); - MockArmy army = MockArmy.GetMockArmy(); + MockArmy army = new MockArmy(); GetSaver().Save(tempFile, system, army); ZipFile file = new ZipFile(tempFile); ZipEntry zipEntry = file.GetEntry(GetEntryName(system)); @@ -181,7 +182,8 @@ 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())); + Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetArmyContentBytes())); + stream.Close(); file.Close(); } finally @@ -243,7 +245,7 @@ [Test()] public void TestFileExtensionsAreCorrectForType() { - Assert.That(GetSaver().GetFileExtension(MockArmy.GetMockArmy()), Is.EqualTo(GetArmyExtension())); + Assert.That(GetSaver().GetFileExtension(new MockArmy()), Is.EqualTo(GetArmyExtension())); Assert.That(GetSaver().GetFileExtension(new MockRace()), Is.EqualTo(GetRaceExtension())); Assert.That(GetSaver().GetFileExtension(new MockGameSystem()), Is.EqualTo(GetGameSystemExtension())); }