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