-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathReadingTest.cs
More file actions
246 lines (202 loc) · 8.49 KB
/
ReadingTest.cs
File metadata and controls
246 lines (202 loc) · 8.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
using DBCD.Providers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
namespace DBCD.Tests
{
[TestClass]
public class ReadingTest
{
static GithubDBDProvider githubDBDProvider = new(true);
static readonly WagoDBCProvider wagoDBCProvider = new();
// Disabled as 7.1.0 definitions are not yet generally available
/*
[TestMethod]
public void TestWDB5ReadingNoIndexData()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Achievement_Category", "7.1.0.23222");
var row = storage[1];
Assert.AreEqual("Statistics", row["Name_lang"]);
}
*/
[TestMethod]
public void TestWDB5Reading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Map", "7.1.0.23222");
var row = storage[451];
Assert.AreEqual("development", row["Directory"]);
}
[TestMethod]
public void TestWDC1Reading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Map", "7.3.5.25600");
var row = storage[451];
Assert.AreEqual("development", row["Directory"]);
}
[TestMethod]
public void TestWDC2Reading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Map", "8.0.1.26231");
var row = storage[451];
Assert.AreEqual("development", row["Directory"]);
}
[TestMethod]
public void TestWDC3Reading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Map", "9.2.7.45745");
var row = storage[451];
Assert.AreEqual("development", row["Directory"]);
}
[TestMethod]
public void TestWDC4Reading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Map", "10.1.0.48480");
var row = storage[2574];
Assert.AreEqual("Dragon Isles", row["MapName_lang"]);
}
[TestMethod]
public void TestWDC5Reading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("Map", "10.2.5.52432");
var row = storage[2574];
Assert.AreEqual("Dragon Isles", row["MapName_lang"]);
}
[TestMethod]
public void TestWDC5ReadingBDBDNoCache()
{
DBCD dbcd = new(wagoDBCProvider, GithubBDBDProvider.GetStream(true));
IDBCDStorage storage = dbcd.Load("Map", "10.2.5.52432");
var row = storage[2574];
Assert.AreEqual("Dragon Isles", row["MapName_lang"]);
}
[TestMethod]
public void TestSparseReading()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("ItemSparse", "9.2.7.45745");
var row = storage[132172];
Assert.AreEqual("Crowbar", row["Display_lang"]);
}
[TestMethod]
public void TestNonInlineRelation()
{
DBCD dbcd = new(wagoDBCProvider, githubDBDProvider);
IDBCDStorage storage = dbcd.Load("MapDifficulty", "9.2.7.45745");
var row = storage[38];
Assert.AreEqual(451, row["MapID"]);
}
[TestMethod]
public void TestEncryptedInfo()
{
DBCD dbcd = new DBCD(wagoDBCProvider, githubDBDProvider);
var storage = dbcd.Load("SpellName", "11.0.2.55959");
foreach (var section in storage.GetEncryptedSections())
{
Console.WriteLine($"Found encrypted section encrypted with key {section.Key} containing {section.Value} rows");
}
}
[TestMethod]
public void TestGithubDBDProviderNoCache()
{
var noCacheProvider = new GithubDBDProvider(false);
noCacheProvider.StreamForTableName("ItemSparse");
}
[TestMethod]
public void TestGithubDBDProviderWithCache()
{
githubDBDProvider.StreamForTableName("ItemSparse");
}
[TestMethod]
public void TestReadingAllDB2s()
{
return; // Only run this test manually
var localDBDProvider = new FilesystemDBDProvider("D:\\Projects\\WoWDBDefs\\definitions");
//var build = "3.3.5.12340"; // WDBC
//var build = "6.0.1.18179"; // WDB2
//var build = "7.0.1.20740"; // WDB3, only 1 DBD sadly
//var build = "7.0.1.20810"; // WDB4, only 2 DBDs sadly
//var build = "7.2.0.23436"; // WDB5, only Map.db2
//var build = "7.3.5.25928"; // WDB6
//var build = "7.3.5.25928"; // WDC1
//var build = "8.0.1.26231"; // WDC2
//var build = "9.1.0.39653"; // WDC3
//var build = "10.1.0.48480"; // WDC4
var build = "11.0.2.56044"; // WDC5
var localDBCProvider = new FilesystemDBCProvider(Path.Combine("DBCCache", build));
var dbcd = new DBCD(localDBCProvider, localDBDProvider);
var allDB2s = wagoDBCProvider.GetAllTableNames();
var attemptedTables = 0;
var successfulTables = 0;
foreach (var tableName in allDB2s)
{
// I think this table is meant to crash the test, so we skip it
if (tableName == "UnitTestSparse")
continue;
if (!localDBDProvider.ContainsBuild(tableName, build))
continue;
attemptedTables++;
try
{
var storage = dbcd.Load(tableName, build);
successfulTables++;
}
catch (FileNotFoundException e)
{
Console.WriteLine($"Failed to load {tableName} for build {build}, does not exist in build.");
successfulTables++; // this counts
}
catch (Exception e)
{
Console.WriteLine("Failed to load " + tableName + " for build " + build + ": " + e.Message + "\n" + e.StackTrace);
}
}
Assert.AreEqual(attemptedTables, successfulTables);
}
//[TestMethod]
//public void TestHotfixApplying()
//{
// DBCD dbcd = new DBCD(dbcProvider, githubDBDProvider);
// var storage = dbcd.Load("ItemSparse");
// var hotfix = new HotfixReader("hotfix.bin");
// var countBefore = storage.Count;
// storage = storage.ApplyingHotfixes(hotfix);
// var countAfter = storage.Count;
// System.Console.WriteLine($"B: {countBefore} => A: {countAfter}");
//}
//[TestMethod]
//public void TestFilesystemDBDProvider()
//{
// DBCD dbcd = new DBCD(dbcProvider, dbdProvider);
// var storage = dbcd.Load("SpellName", locale: Locale.EnUS);
// // Spell is present in Classic Era -> Retail: https://www.wowhead.com/spell=17/
// Assert.AreEqual("Power Word: Shield", storage[17]["Name_lang"]);
//}
[TestMethod]
public void TestEnumReadingSingle()
{
var dbcd = new DBCD(wagoDBCProvider, githubDBDProvider, new GithubEnumProvider(useCache: true));
var storage = dbcd.Load("SpellEffect", "12.0.1.66220");
var spellEffectRow = storage[1177101];
Assert.AreEqual(spellEffectRow.IsEnumMember("Effect", "SET_PLAYER_DATA_ELEMENT_ACCOUNT"), true);
}
[TestMethod]
public void TestEnumReadingArray()
{
var dbcd = new DBCD(wagoDBCProvider, githubDBDProvider, new GithubEnumProvider(useCache: true));
var storage = dbcd.Load("SpellMisc", "12.0.1.66220");
var spellMiscRow = storage[66253];
Assert.AreEqual(spellMiscRow.HasFlag("Attributes", 0, "ON_NEXT_SWING"), false);
Assert.AreEqual(spellMiscRow.HasFlag("Attributes", 0, "HIDDEN_CLIENTSIDE"), true);
// Throws an exception because the Enum Member is not in the Enum
Assert.ThrowsException<KeyNotFoundException>(() => spellMiscRow.HasFlag("Attributes", 1, "HIDDEN_CLIENTSIDE"));
}
}
}