Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
annotate API/Savers/IWarFoundryFileSaverTests.cs @ 227:d8cd6b259a9f
Re #359: Add "only contained" attribute to unit types
* Test to make sure sub-units are removed from the army
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 16 Apr 2012 20:45:45 +0100 |
parents | 32b3e41bc8f0 |
children | e173c5512067 |
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; |
95
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
2 using System.Collections; |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
3 using System.Collections.Generic; |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 using System.IO; |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using IBBoard.WarFoundry.API.Objects; |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using IBBoard.WarFoundry.API.Objects.Mock; |
95
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
7 using ICSharpCode.SharpZipLib.Zip; |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using NUnit.Framework; |
94
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
9 using NUnit.Framework.SyntaxHelpers; |
98
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
10 using ICSharpCode.SharpZipLib.Core; |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
11 using IBBoard.IO; |
101
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
12 using IBBoard.WarFoundry.API.Factories; |
91
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 namespace IBBoard.WarFoundry.API.Savers |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 public abstract class IWarFoundryFileSaverTests |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 { |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 [Test()] |
92
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
19 public void TestSaverCreatesFile() |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 { |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 string tempFile = Path.GetTempFileName(); |
98
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
22 |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 try |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 { |
92
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
25 bool saved = GetSaver().Save(tempFile, new MockGameSystem()); |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
26 Assert.That(saved); |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 Assert.That(File.Exists(tempFile)); |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 } |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 finally |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 { |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 if (File.Exists(tempFile)) |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 { |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 File.Delete(tempFile); |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 } |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 } |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 } |
95
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
37 |
92
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
38 [Test()] |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
39 public void TestSaverCreatesZipFile() |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
40 { |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
41 string tempFile = Path.GetTempFileName(); |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
42 try |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
43 { |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
44 GetSaver().Save(tempFile, new MockGameSystem()); |
93
72b2f9a5fe8f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
45 ZipFile file = new ZipFile(tempFile); |
72b2f9a5fe8f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
46 file.Close(); |
92
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
47 } |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
48 finally |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
49 { |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
50 if (File.Exists(tempFile)) |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
51 { |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
52 File.Delete(tempFile); |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
53 } |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
54 } |
43c44d0bf97f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
55 } |
95
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
56 |
94
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
57 [Test()] |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
58 public void TestSaverCreatesSingleEntryForOneObject() |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
59 { |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
60 string tempFile = Path.GetTempFileName(); |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
61 try |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
62 { |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
63 GetSaver().Save(tempFile, new MockGameSystem()); |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
64 ZipFile file = new ZipFile(tempFile); |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
65 Assert.That(file.Count, Is.EqualTo(1)); |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
66 file.Close(); |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
67 } |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
68 finally |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
69 { |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
70 if (File.Exists(tempFile)) |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
71 { |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
72 File.Delete(tempFile); |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
73 } |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
74 } |
10da200c7799
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
75 } |
95
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
76 |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
77 [Test()] |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
78 public void TestSaverCreatesSingleEntryWithCorrectNameForOneObject() |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
79 { |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
80 string tempFile = Path.GetTempFileName(); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
81 try |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
82 { |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
83 MockGameSystem obj = new MockGameSystem(); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
84 GetSaver().Save(tempFile, obj); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
85 ZipFile file = new ZipFile(tempFile); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
86 IEnumerator enumerator = file.GetEnumerator(); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
87 enumerator.MoveNext(); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
88 ZipEntry current = (ZipEntry)enumerator.Current; |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
89 Assert.That(current.Name, Is.EqualTo(GetEntryName(obj))); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
90 Assert.That(current.Name, Text.EndsWith(GetFileExtensionForType(obj))); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
91 file.Close(); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
92 } |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
93 finally |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
94 { |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
95 if (File.Exists(tempFile)) |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
96 { |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
97 File.Delete(tempFile); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
98 } |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
99 } |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
100 } |
98
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
101 |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
102 [Test()] |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
103 public void TestSaverCreatesSingleEntryWithCorrectContentForOneSystem() |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
104 { |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
105 string tempFile = Path.GetTempFileName(); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
106 try |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
107 { |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
108 MockGameSystem obj = new MockGameSystem(); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
109 GetSaver().Save(tempFile, obj); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
110 ZipFile file = new ZipFile(tempFile); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
111 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
112 Stream stream = file.GetInputStream(zipEntry); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
113 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentBytes())); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
114 file.Close(); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
115 } |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
116 finally |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
117 { |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
118 if (File.Exists(tempFile)) |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
119 { |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
120 File.Delete(tempFile); |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
121 } |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
122 } |
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
123 } |
99
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
124 |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
125 [Test()] |
177
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
126 public void TestSaverCreatesSingleEntryWithCorrectContentForOtherSystem() |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
127 { |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
128 string tempFile = Path.GetTempFileName(); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
129 try |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
130 { |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
131 GameSystem obj = CreateOtherSystem(); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
132 GetSaver().Save(tempFile, obj); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
133 ZipFile file = new ZipFile(tempFile); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
134 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
135 Stream stream = file.GetInputStream(zipEntry); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
136 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetOtherGameSystemContentBytes())); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
137 file.Close(); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
138 } |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
139 finally |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
140 { |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
141 if (File.Exists(tempFile)) |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
142 { |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
143 File.Delete(tempFile); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
144 } |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
145 } |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
146 } |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
147 |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
148 private GameSystem CreateOtherSystem() |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
149 { |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
150 GameSystem system = new GameSystem("otherSystem", "Other System", new DummyWarFoundryFactory()); |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
151 system.AllowAllies = true; |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
152 system.WarnOnError = false; |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
153 system.SystemArmyDefaultSize = 2000; |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
154 return system; |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
155 } |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
156 |
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
157 [Test()] |
99
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
158 public void TestSaverCreatesSingleEntryWithCorrectContentForOneArmy() |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
159 { |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
160 string tempFile = Path.GetTempFileName(); |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
161 try |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
162 { |
172
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
163 MockArmy obj = new MockArmy(); |
99
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
164 GetSaver().Save(tempFile, obj); |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
165 ZipFile file = new ZipFile(tempFile); |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
166 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
167 Stream stream = file.GetInputStream(zipEntry); |
172
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
168 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetArmyContentBytes())); |
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
169 stream.Close(); |
99
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
170 file.Close(); |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
171 } |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
172 finally |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
173 { |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
174 if (File.Exists(tempFile)) |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
175 { |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
176 File.Delete(tempFile); |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
177 } |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
178 } |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
179 } |
100
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
180 |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
181 [Test()] |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
182 public void TestSaverCreatesTwoEntriesForOneSystemOneArmy() |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
183 { |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
184 string tempFile = Path.GetTempFileName(); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
185 try |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
186 { |
172
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
187 GetSaver().Save(tempFile, new MockGameSystem(), new MockArmy()); |
100
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
188 ZipFile file = new ZipFile(tempFile); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
189 Assert.That(file.Count, Is.EqualTo(2)); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
190 file.Close(); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
191 } |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
192 finally |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
193 { |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
194 if (File.Exists(tempFile)) |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
195 { |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
196 File.Delete(tempFile); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
197 } |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
198 } |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
199 } |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
200 |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
201 [Test()] |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
202 public void TestSaverCreatesTwoEntriesWithCorrectContentForOneSystemOneArmy() |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
203 { |
101
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
204 //This doesn't make much sense (system and army in one file) but at the time of writing then Race saving isn't implemented |
100
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
205 string tempFile = Path.GetTempFileName(); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
206 try |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
207 { |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
208 MockGameSystem system = new MockGameSystem(); |
172
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
209 MockArmy army = new MockArmy(); |
100
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
210 GetSaver().Save(tempFile, system, army); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
211 ZipFile file = new ZipFile(tempFile); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
212 ZipEntry zipEntry = file.GetEntry(GetEntryName(system)); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
213 Stream stream = file.GetInputStream(zipEntry); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
214 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentBytes())); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
215 zipEntry = file.GetEntry(GetEntryName(army)); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
216 stream = file.GetInputStream(zipEntry); |
172
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
217 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetArmyContentBytes())); |
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
218 stream.Close(); |
100
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
219 file.Close(); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
220 } |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
221 finally |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
222 { |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
223 if (File.Exists(tempFile)) |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
224 { |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
225 File.Delete(tempFile); |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
226 } |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
227 } |
5addcb8f7766
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
228 } |
101
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
229 |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
230 [Test()] |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
231 public void TestSaverCreatesTwoEntriesForTwoSystems() |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
232 { |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
233 string tempFile = Path.GetTempFileName(); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
234 try |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
235 { |
177
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
236 GetSaver().Save(tempFile, new MockGameSystem(), CreateOtherSystem()); |
101
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
237 ZipFile file = new ZipFile(tempFile); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
238 Assert.That(file.Count, Is.EqualTo(2)); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
239 file.Close(); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
240 } |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
241 finally |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
242 { |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
243 if (File.Exists(tempFile)) |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
244 { |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
245 File.Delete(tempFile); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
246 } |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
247 } |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
248 } |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
249 |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
250 [Test()] |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
251 public void TestSaverCreatesTwoEntriesWithCorrectContentForTwoSystems() |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
252 { |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
253 string tempFile = Path.GetTempFileName(); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
254 try |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
255 { |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
256 MockGameSystem system1 = new MockGameSystem(); |
177
01f7a713fe82
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
257 GameSystem system2 = CreateOtherSystem(); |
101
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
258 GetSaver().Save(tempFile, system1, system2); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
259 ZipFile file = new ZipFile(tempFile); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
260 ZipEntry zipEntry = file.GetEntry(GetEntryName(system1)); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
261 Stream stream = file.GetInputStream(zipEntry); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
262 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentBytes())); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
263 zipEntry = file.GetEntry(GetEntryName(system2)); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
264 stream = file.GetInputStream(zipEntry); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
265 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetOtherGameSystemContentBytes())); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
266 file.Close(); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
267 } |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
268 finally |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
269 { |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
270 if (File.Exists(tempFile)) |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
271 { |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
272 File.Delete(tempFile); |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
273 } |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
274 } |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
275 } |
97
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
276 |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
277 [Test()] |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
278 public void TestFileExtensionsAreCorrectForType() |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
279 { |
172
c026c02583ca
* Remove MockArmy.GetMockArmy as it only causes problems in unit tests
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
280 Assert.That(GetSaver().GetFileExtension(new MockArmy()), Is.EqualTo(GetArmyExtension())); |
97
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
281 Assert.That(GetSaver().GetFileExtension(new MockRace()), Is.EqualTo(GetRaceExtension())); |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
282 Assert.That(GetSaver().GetFileExtension(new MockGameSystem()), Is.EqualTo(GetGameSystemExtension())); |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
283 } |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
284 |
176
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
285 [Test()] |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
286 public void TestPointsValueAbbreviationsSaved() |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
287 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
288 string tempFile = Path.GetTempFileName(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
289 try |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
290 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
291 MockGameSystem obj = new MockGameSystem(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
292 string plural = "ptii"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
293 string singular = "ptus"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
294 obj.SystemPtsAbbrevPlural = plural; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
295 obj.SystemPtsAbbrevSingle = singular; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
296 GetSaver().Save(tempFile, obj); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
297 ZipFile file = new ZipFile(tempFile); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
298 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
299 Stream stream = file.GetInputStream(zipEntry); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
300 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentWithPointsAbbrevsBytes(singular, plural))); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
301 file.Close(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
302 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
303 finally |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
304 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
305 if (File.Exists(tempFile)) |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
306 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
307 File.Delete(tempFile); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
308 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
309 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
310 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
311 |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
312 [Test()] |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
313 public void TestPointsValueNamesSaved() |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
314 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
315 string tempFile = Path.GetTempFileName(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
316 try |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
317 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
318 MockGameSystem obj = new MockGameSystem(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
319 string plural = "pointii"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
320 string singular = "pointus"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
321 obj.SystemPtsNamePlural = plural; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
322 obj.SystemPtsNameSingle = singular; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
323 GetSaver().Save(tempFile, obj); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
324 ZipFile file = new ZipFile(tempFile); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
325 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
326 Stream stream = file.GetInputStream(zipEntry); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
327 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentWithPointsNameBytes(singular, plural))); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
328 file.Close(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
329 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
330 finally |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
331 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
332 if (File.Exists(tempFile)) |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
333 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
334 File.Delete(tempFile); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
335 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
336 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
337 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
338 |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
339 [Test()] |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
340 public void TestPointsValueAbbreviationsAndNamesSaved() |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
341 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
342 string tempFile = Path.GetTempFileName(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
343 try |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
344 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
345 MockGameSystem obj = new MockGameSystem(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
346 string plural = "ptii"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
347 string singular = "ptus"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
348 string pluralName = "pointii"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
349 string singularName = "pointus"; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
350 obj.SystemPtsAbbrevPlural = plural; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
351 obj.SystemPtsAbbrevSingle = singular; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
352 obj.SystemPtsNamePlural = pluralName; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
353 obj.SystemPtsNameSingle = singularName; |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
354 GetSaver().Save(tempFile, obj); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
355 ZipFile file = new ZipFile(tempFile); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
356 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
357 Stream stream = file.GetInputStream(zipEntry); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
358 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentWithPointsAbbrevsAndNameBytes(singular, plural, singularName, pluralName))); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
359 file.Close(); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
360 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
361 finally |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
362 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
363 if (File.Exists(tempFile)) |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
364 { |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
365 File.Delete(tempFile); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
366 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
367 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
368 } |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
369 |
178
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
370 [Test()] |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
371 public void TestGameSystemWithCategories() |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
372 { |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
373 string tempFile = Path.GetTempFileName(); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
374 try |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
375 { |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
376 MockGameSystem obj = new MockGameSystem(); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
377 Category heroCat = new Category("cat1", "Heroes"); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
378 heroCat.MaximumPercentage = 25; |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
379 heroCat.MaximumPoints = 1000; |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
380 obj.AddCategory(heroCat); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
381 Category warriorCat = new Category("cat2", "Warriors"); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
382 warriorCat.MinimumPercentage = 35; |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
383 warriorCat.MinimumPoints = 500; |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
384 obj.AddCategory(warriorCat); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
385 GetSaver().Save(tempFile, obj); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
386 ZipFile file = new ZipFile(tempFile); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
387 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
388 Stream stream = file.GetInputStream(zipEntry); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
389 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentWithCategories())); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
390 file.Close(); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
391 } |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
392 finally |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
393 { |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
394 if (File.Exists(tempFile)) |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
395 { |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
396 File.Delete(tempFile); |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
397 } |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
398 } |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
399 } |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
400 |
179
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
401 [Test()] |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
402 public void TestGameSystemWithStatLines() |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
403 { |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
404 string tempFile = Path.GetTempFileName(); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
405 try |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
406 { |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
407 MockGameSystem obj = new MockGameSystem(); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
408 //MockGameSystem already has a stat line, so add one more |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
409 SystemStats systemStats = new SystemStats("stats"); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
410 systemStats.AddStatSlot("M"); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
411 systemStats.AddStatSlot("S"); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
412 systemStats.AddStatSlot("T"); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
413 systemStats.AddStatSlot("W"); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
414 obj.AddSystemStats(systemStats); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
415 obj.StandardSystemStatsID = "stats"; |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
416 GetSaver().Save(tempFile, obj); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
417 ZipFile file = new ZipFile(tempFile); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
418 ZipEntry zipEntry = file.GetEntry(GetEntryName(obj)); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
419 Stream stream = file.GetInputStream(zipEntry); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
420 Assert.That(StreamUtil.ToBytes(stream), Is.EqualTo(GetGameSystemContentWithStats())); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
421 file.Close(); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
422 } |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
423 finally |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
424 { |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
425 if (File.Exists(tempFile)) |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
426 { |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
427 File.Delete(tempFile); |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
428 } |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
429 } |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
430 } |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
431 |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
432 protected abstract IWarFoundryFileSaver GetSaver(); |
95
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
433 |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
434 protected abstract string GetEntryName(WarFoundryLoadedObject obj); |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
435 |
db6db25921fb
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
94
diff
changeset
|
436 protected abstract string GetFileExtensionForType(WarFoundryLoadedObject obj); |
97
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
437 |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
438 protected abstract string GetArmyExtension(); |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
439 |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
440 protected abstract string GetRaceExtension(); |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
441 |
45b80fed5e2a
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
442 protected abstract string GetGameSystemExtension(); |
98
49c5e24decb9
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
443 |
99
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
444 protected abstract byte[] GetGameSystemContentBytes(); |
101
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
445 |
08fd75eafb67
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
100
diff
changeset
|
446 protected abstract byte[] GetOtherGameSystemContentBytes(); |
99
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
447 |
dd384f35a96f
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
448 protected abstract byte[] GetArmyContentBytes(); |
176
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
449 |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
450 protected abstract byte[] GetGameSystemContentWithPointsAbbrevsBytes(string singular, string plural); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
451 |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
452 protected abstract byte[] GetGameSystemContentWithPointsNameBytes(string singular, string plural); |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
453 |
9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
172
diff
changeset
|
454 protected abstract byte[] GetGameSystemContentWithPointsAbbrevsAndNameBytes(string singular, string plural, string singularName, string pluralName); |
178
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
455 |
50b8466783ed
Re #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
177
diff
changeset
|
456 protected abstract byte[] GetGameSystemContentWithCategories(); |
179
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
457 |
32b3e41bc8f0
Fixes #338: WarFoundry.API - Save System Data
IBBoard <dev@ibboard.co.uk>
parents:
178
diff
changeset
|
458 protected abstract byte[] GetGameSystemContentWithStats(); |
91
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
459 } |
98539b2fe8fa
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
460 } |