annotate API/Savers/Xml/WarFoundryXmlFileSaverTests.cs @ 99:dd384f35a96f

Re #324: Add saving of Race and System data to files * Start to migrate Army saving to same structure * Add first test * Give MockArmy a specific ID
author IBBoard <dev@ibboard.co.uk>
date Wed, 09 Mar 2011 20:55:35 +0000
parents 49c5e24decb9
children 08fd75eafb67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 using System;
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 using NUnit.Framework;
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 using System.IO;
95
db6db25921fb Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 91
diff changeset
4 using IBBoard.WarFoundry.API.Objects;
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
5 using IBBoard.Lang;
91
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 namespace IBBoard.WarFoundry.API.Savers.Xml
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 {
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 [TestFixture()]
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 public class WarFoundryXmlFileSaverTests : IWarFoundryFileSaverTests
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 protected override IWarFoundryFileSaver GetSaver()
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 return new WarFoundryXmlFileSaver();
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 }
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
16
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
17 protected override string GetEntryName(WarFoundryLoadedObject obj)
95
db6db25921fb Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 91
diff changeset
18 {
97
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
19 return obj.ID + GetFileExtensionForType(obj);
95
db6db25921fb Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 91
diff changeset
20 }
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
21
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
22 protected override string GetFileExtensionForType(WarFoundryLoadedObject obj)
95
db6db25921fb Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 91
diff changeset
23 {
db6db25921fb Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 91
diff changeset
24 return GetSaver().GetFileExtension(obj);
db6db25921fb Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 91
diff changeset
25 }
97
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
26
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
27 protected override string GetArmyExtension()
97
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
28 {
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
29 return ".armyx";
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
30 }
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
31
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
32 protected override string GetRaceExtension()
97
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
33 {
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
34 return ".racex";
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
35 }
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
36
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
37 protected override string GetGameSystemExtension()
97
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
38 {
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
39 return ".systemx";
45b80fed5e2a Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 95
diff changeset
40 }
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
41
99
dd384f35a96f Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
42 protected override byte[] GetGameSystemContentBytes()
98
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
43 {
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
44 return StringManipulation.StringToBytes(@"<?xml version=""1.0"" encoding=""UTF-8""?><system xmlns=""http://ibboard.co.uk/warfoundry/system"" xmlns:cats=""http://ibboard.co.uk/warfoundry/cats"" id=""mocksystem"" name=""Mock Game System"" defaultArmySize=""0"" warn=""false"" allowAllies=""false""><categories /><sysStatsList defaultStats=""default""><sysStats id=""default"" /></sysStatsList></system>");
49c5e24decb9 Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
45 }
99
dd384f35a96f Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
46
dd384f35a96f Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
47 protected override byte[] GetArmyContentBytes ()
dd384f35a96f Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
48 {
dd384f35a96f Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
49 return StringManipulation.StringToBytes(@"<?xml version=""1.0"" encoding=""UTF-8""?><army xmlns=""http://ibboard.co.uk/warfoundry/army"" xmlns:core=""http://ibboard.co.uk/warfoundry/core"" id=""MockArmy"" name=""Mock Army"" system=""mocksystem"" race=""mockrace"" maxPoints=""2000""><units /></army>");
dd384f35a96f Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
50 }
91
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 }
98539b2fe8fa Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }