for Push.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using KssSmaPlaLib.AutoTest.Command.Definition;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KssSmaPlaLib.AutoTest.Command.Alias
|
||||
{
|
||||
public class CommandAliasUxer
|
||||
{
|
||||
private static Dictionary<string, CommandEnumUxer.Command> _reverseMap = new Dictionary<string, CommandEnumUxer.Command>();
|
||||
|
||||
public static void SetAleiasDic(Dictionary<string, CommandEnumUxer.Command> dic)
|
||||
{
|
||||
_reverseMap = dic;
|
||||
}
|
||||
|
||||
public static bool TryTranslate(string userCommand, out CommandEnumUxer.Command command)
|
||||
=> _reverseMap.TryGetValue(userCommand, out command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using KssSmaPlaLib.AutoTest.Command.Definition;
|
||||
using KssSmaPlaLib.AutoTest.Command.Translator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KssSmaPlaLib.AutoTest.Command.Alias.Ini
|
||||
{
|
||||
public static class IniReaderUxer
|
||||
{
|
||||
public static bool Try(string iniFilePath, out Dictionary<string, CommandEnumUxer.Command> dic, out string resultMessage)
|
||||
{
|
||||
dic = new Dictionary<string, CommandEnumUxer.Command>();
|
||||
resultMessage = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (!File.Exists(iniFilePath))
|
||||
{
|
||||
resultMessage = "エイリアスファイルが存在しません。";
|
||||
return false;
|
||||
}
|
||||
|
||||
var lines = File.ReadAllLines(iniFilePath, System.Text.Encoding.GetEncoding("shift_jis"));
|
||||
|
||||
// ここでDTOにパース(例:セクションごとに分ける、キーと値を読み込むなど)
|
||||
// ↓仮の処理(実際はINIパーサーCLがあると別府)
|
||||
foreach (var line in lines)
|
||||
{
|
||||
if (line.StartsWith("#") ||
|
||||
line.StartsWith(";") ||
|
||||
string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
|
||||
var parts = line.Split('=');
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
var command = parts[0].Trim();
|
||||
var alias = parts[1].Trim();
|
||||
|
||||
if (!CommandTranslatorUxer.TryTranslate(command, out var commandEnum))
|
||||
{
|
||||
resultMessage = $"エイリアスファイルでコマンド名が不正です。[コマンド名:{command}]";
|
||||
return false;
|
||||
}
|
||||
|
||||
// エイリアス辞書登録
|
||||
dic[alias] = commandEnum;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
resultMessage = $"エイリアスロードに失敗しました。[エラー内容:{ex.Message}]";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using KssSmaPlaLib.AutoTest.Command.Alias.Ini;
|
||||
using KssSmaPlaLib.AutoTest.Command.Definition;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KssSmaPlaLib.AutoTest.Command.Alias.Loader
|
||||
{
|
||||
public static class CommandAliasLoaderUxer
|
||||
{
|
||||
public const string COMMAND_ALIAS_FILE_PATH = ".\\command_alias.ini";
|
||||
|
||||
public static bool Try(out Dictionary<string,CommandEnumUxer.Command>dic, out string resultMessage)
|
||||
{
|
||||
resultMessage = string.Empty;
|
||||
|
||||
if (!IniReaderUxer.Try(COMMAND_ALIAS_FILE_PATH, out dic, out var messageForMe))
|
||||
{
|
||||
resultMessage = messageForMe;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KssSmaPlaLib.AutoTest.Command.Definition
|
||||
{
|
||||
public class CommandEnumUxer
|
||||
{
|
||||
/// <summary>
|
||||
/// UIステップテストコマンド
|
||||
/// </summary>
|
||||
public enum Command
|
||||
{
|
||||
None,
|
||||
Sleep,
|
||||
SetText,
|
||||
PushButton,
|
||||
TryDbMoshimoshi
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KssSmaPlaLib.AutoTest.Command.Definition
|
||||
{
|
||||
public static class CommandParserUxer
|
||||
{
|
||||
private static readonly Dictionary<string, CommandEnumUxer.Command> _map = new Dictionary<string, CommandEnumUxer.Command>()
|
||||
{
|
||||
{ "Sleep", CommandEnumUxer.Command.Sleep },
|
||||
{ "SetText", CommandEnumUxer.Command.SetText },
|
||||
{ "PushButton", CommandEnumUxer.Command.PushButton },
|
||||
{ "TryDbMoshimoshi", CommandEnumUxer.Command.TryDbMoshimoshi }
|
||||
};
|
||||
|
||||
public static bool TryParse(string commandStr, out CommandEnumUxer.Command command)
|
||||
=> _map.TryGetValue(commandStr, out command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using KssSmaPlaLib.AutoTest.Command.Definition;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KssSmaPlaLib.AutoTest.Command.Translator
|
||||
{
|
||||
public static class CommandTranslatorUxer
|
||||
{
|
||||
private static readonly Dictionary<string, CommandEnumUxer.Command> _reverseMap = new Dictionary<string, CommandEnumUxer.Command>()
|
||||
{
|
||||
{ "寝る", CommandEnumUxer.Command.Sleep },
|
||||
{ "あああをセット", CommandEnumUxer.Command.SetText },
|
||||
{ "ボタン押す", CommandEnumUxer.Command.PushButton },
|
||||
{ "もしもしDB", CommandEnumUxer.Command.TryDbMoshimoshi }
|
||||
};
|
||||
|
||||
public static bool TryTranslate(string userCommand, out CommandEnumUxer.Command command)
|
||||
=> _reverseMap.TryGetValue(userCommand, out command);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user