Commit 7afdb8f4 authored by nanahira's avatar nanahira

add test methods

parent 1b31d771
......@@ -34,11 +34,13 @@ public static class GameStringManager
return return_value;
}
public static void initialize(string path)
public static bool initialize(string path, bool test = false)
{
string text = System.IO.File.ReadAllText(path);
string st = text.Replace("\r", "");
string[] lines = st.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
bool success = true;
bool found = false;
foreach (string line in lines)
{
if (line.Length > 1 && line.Substring(0, 1) == "!")
......@@ -46,6 +48,7 @@ public static class GameStringManager
string[] mats = line.Substring(1, line.Length - 1).Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length > 2)
{
found = true;
hashedString a = new hashedString();
a.region = mats[0];
try
......@@ -54,6 +57,7 @@ public static class GameStringManager
}
catch (Exception e)
{
success = false;
Program.DEBUGLOG(e);
}
a.content = "";
......@@ -62,14 +66,17 @@ public static class GameStringManager
a.content += mats[i] + " ";
}
a.content = a.content.Substring(0, a.content.Length - 1);
hashedStrings.Add(a);
if (a.region == "setname")
{
xilies.Add(a);
if(!test) {
hashedStrings.Add(a);
if (a.region == "setname")
{
xilies.Add(a);
}
}
}
}
}
return (success && found);
}
public static string get(string region, int hashCode)
......@@ -148,4 +155,3 @@ public static class GameStringManager
return formatLocation(gps.location, gps.sequence);
}
}
......@@ -7,11 +7,12 @@ namespace YGOSharp
{
public static List<Banlist> Banlists { get; private set; }
public static void initialize(string fileName)
public static bool initialize(string fileName, bool test = false)
{
Banlists = new List<Banlist>();
List<Banlist> new_list = new List<Banlist>();
Banlist current = null;
StreamReader reader = new StreamReader(fileName);
bool success = true;
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
......@@ -25,7 +26,7 @@ namespace YGOSharp
{
current = new Banlist();
current.Name = line.Substring(1, line.Length - 1);
Banlists.Add(current);
new_list.Add(current);
continue;
}
if (!line.Contains(" "))
......@@ -39,13 +40,18 @@ namespace YGOSharp
}
catch (System.Exception e)
{
success = false;
UnityEngine.Debug.Log(line);
UnityEngine.Debug.Log(e);
}
}
current = new Banlist();
current.Name ="N/A";
Banlists.Add(current);
new_list.Add(current);
if(!test) {
Banlists = new_list;
}
return (success && new_list.Count > 1);
}
public static int GetIndex(uint hash)
......@@ -101,4 +107,4 @@ namespace YGOSharp
}
}
}
\ No newline at end of file
}
......@@ -16,17 +16,19 @@ namespace YGOSharp
public static string nullString = "";
internal static bool initialize(string databaseFullPath)
internal static bool initialize(string databaseFullPath, bool test = false)
{
nullName = InterString.Get("未知卡片");
nullString = "";
nullString += "欢迎使用 KoishiPro2 iOS,本软件免责声明:[url=http://koishi.222diy.gdn/lab.html][u]http://koishi.222diy.gdn/lab.html[/u][/url]";
nullString += "\r\n\r\n";
nullString += "KoishiPro2 iOS的用户QQ群627975038,游戏中遇到任何bug欢迎提交";
nullString += "\r\n\r\n";
nullString += "更多关于电脑/安卓版KoishiPro及7210服务器的信息可加QQ群338443272";
nullString += "\r\n\r\n";
nullString += "喜欢游戏王DIY的朋友欢迎来222服QQ群642043095";
if(!test) {
nullName = InterString.Get("未知卡片");
nullString = "";
nullString += "欢迎使用 KoishiPro2 iOS,本软件免责声明:[url=http://koishi.222diy.gdn/lab.html][u]http://koishi.222diy.gdn/lab.html[/u][/url]";
nullString += "\r\n\r\n";
nullString += "KoishiPro2 iOS的用户QQ群627975038,游戏中遇到任何bug欢迎提交";
nullString += "\r\n\r\n";
nullString += "更多关于电脑/安卓版KoishiPro及7210服务器的信息可加QQ群338443272";
nullString += "\r\n\r\n";
nullString += "喜欢游戏王DIY的朋友欢迎来222服QQ群642043095";
}
bool success = true;
try {
using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath))
......@@ -39,7 +41,7 @@ namespace YGOSharp
{
while (reader.Read())
{
LoadCard(reader);
LoadCard(reader, test);
}
}
}
......@@ -86,10 +88,10 @@ namespace YGOSharp
return returnValue;
}
private static void LoadCard(IDataRecord reader)
private static void LoadCard(IDataRecord reader, bool test = false)
{
Card card = new Card(reader);
if (!_cards.ContainsKey(card.Id))
if (!_cards.ContainsKey(card.Id) && !test)
{
_cards.Add(card.Id, card);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment