forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTest1.cs
More file actions
63 lines (54 loc) · 2.33 KB
/
Copy pathUnitTest1.cs
File metadata and controls
63 lines (54 loc) · 2.33 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
using System.Collections.Generic;
using System.IO;
using System.Xml;
using L2dotNET.templates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace L2dotNET.Tests
{
[TestClass]
public class UnitTest1
{
private Dictionary<int, PcTemplate> templates = new Dictionary<int, PcTemplate>();
[TestMethod]
public void TestMethod1()
{
//const string folderPath = @"./data/xml/classes";
//foreach (string file in Directory.EnumerateFiles(folderPath, "*.xml"))
//{
// //string contents = File.ReadAllText(file);
//}
XmlDocument doc = new XmlDocument();
string[] xmlFilesArray = Directory.GetFiles(@"data\xml\classes\");
foreach (string i in xmlFilesArray)
{
doc.Load(i);
XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/class");
if (nodes == null)
continue;
foreach (XmlNode node in nodes)
{
XmlElement ownerElement = node.Attributes?[0].OwnerElement;
if ((ownerElement == null) || !"class".Equals(ownerElement.Name))
continue;
//ClassIds classId = (ClassIds)int.Parse(attrs.Item(0).Value);
StatsSet set = new StatsSet();
for (XmlNode cd = node.FirstChild; cd != null; cd = cd.NextSibling)
if ((cd.NextSibling != null) && "set".Equals(cd.NextSibling.Name) && (cd.NextSibling != null))
{
XmlNamedNodeMap attrs = cd.NextSibling.Attributes;
if (attrs == null)
continue;
string name = attrs.GetNamedItem("name").Value;
string value = attrs.GetNamedItem("val").Value;
set.Set(name, value);
}
else
break;
////PcTemplate pcTempl = new PcTemplate(classId, set);
////templates.Add((int)pcTempl.ClassId, pcTempl);
//System.Diagnostics.Trace.WriteLine($"Added template for: {pcTempl.ClassId}");
}
}
}
}
}