for Push.

This commit is contained in:
nobobo
2026-06-01 13:23:34 +09:00
parent 9e093ea99f
commit a6550e9928
93 changed files with 10393 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
using KssSmaPlaLib.AutoTest.Script.Models;
using KssSmaPlaLib.AutoTest.Script.Parse;
using System;
using System.IO;
using System.Linq;
namespace KssSmaPlaLib.AutoTest.Script.Load
{
/// <summary>
/// UIテストスクリプトローダー
/// </summary>
public static class LoadTryUxer
{
/// <summary>
/// スクリプトファイルパス
/// </summary>
private const string UITEST_SCRIPT_FILE_PATH = "./test_script.ini";
/// <summary>
/// スクリプトロード
/// </summary>
/// <param name="scriptDto">[出力]テストスクリプトデータ</param>
/// <param name="resultMessage">[出力]メッセージ</param>
/// <returns>成否</returns>
public static bool TryLoad(out StepInfoDTO stepInfo, out string resultMessage)
{
stepInfo = new StepInfoDTO();
resultMessage = string.Empty;
try
{
if (!File.Exists(UITEST_SCRIPT_FILE_PATH))
{
resultMessage = "スクリプトファイルが存在しません。";
return false;
}
var lines = File.ReadAllLines(UITEST_SCRIPT_FILE_PATH, System.Text.Encoding.GetEncoding("shift_jis"));
stepInfo.Description = "なんか詳細...(笑)";
stepInfo.InitialStepName = "なんか初期ステップ名...(笑)";
// ここでDTOにパース(例:セクションごとに分ける、キーと値を読み込むなど)
// ↓仮の処理(実際はINIパーサーCLがあると別府)
foreach (var line in lines)
{
if (line.StartsWith("#") ||
line.StartsWith(";") ||
string.IsNullOrWhiteSpace(line))
continue;
// 左辺と右辺分離
var parts = line.Split(new[] { '=' }, 2);
// 要素数違いは飛ばす
if (parts.Length != 2) continue;
// 要素取得
var no = parts[0].Trim();
var text = parts[1].Trim();
// No重複チェック
if (stepInfo.StepList.Any(m => m.StepNo == no))
{
resultMessage = $"ステップNoが重複しています。[ステップNo:{no}]";
return false;
}
// RawDTO
var raw = new StepDTO(no, text);
// バリデーションと変換
if (!ParseTryUxer.TryParse(raw, out var parsed, out string messageForMe))
{
resultMessage = $"ステップエラーです。[行:{line},エラー内容:{messageForMe}";
return false;
}
// 正常:リストに追加
stepInfo.StepList.Add(parsed);
}
return true;
}
catch (Exception ex)
{
resultMessage = $"スクリプトロードに失敗しました。[エラー内容:{ex.Message}]";
return false;
}
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using KssSmaPlaLib.AutoTest.Command.Definition;
using KssSmaPlaLib.AutoTest.Script.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KssSmaPlaLib.AutoTest.Script.Models
{
/// <summary>
/// パース済みのステップDTO(1ステップの情報)
/// </summary>
public class ParsedStepDTO
{
public string StepNo => Raw.StepNo;
public CommandEnumUxer.Command Command { get; set; }
public List<string> Parameters { get; set; }
public StepDTO Raw { get; }
public ParsedStepDTO(StepDTO raw)
{
Raw = raw;
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KssSmaPlaLib.AutoTest.Script.Models
{
/// <summary>
/// ステップDTO(1ステップの情報)
/// </summary>
public class StepDTO
{
/// <summary>
/// ステップ番号
/// </summary>
public string StepNo { get; set; }
/// <summary>
/// ステップテキスト
/// </summary>
public string StepText { get; set; }
public StepDTO(string stepNo, string stepText)
{ this.StepNo = stepNo; this.StepText = stepText; }
}
}
+19
View File
@@ -0,0 +1,19 @@
using KssSmaPlaLib.AutoTest.Script;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KssSmaPlaLib.AutoTest.Script.Models
{
/// <summary>
/// UIテストステップ全体情報
/// </summary>
public class StepInfoDTO
{
public List<ParsedStepDTO> StepList { get; set; } = new List<ParsedStepDTO>();
public string InitialStepName { get; set; } // 最初に実行するステップ名
public string Description { get; set; } // ステップ群の説明(任意)
}
}
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace KssSmaPlaLib.AutoTest.Script.Parse.Function
{
public class FunctionTryUxer
{
public static bool TryFunction(string input, out string functionName, out List<string> funcArgList,out string resultMessage)
{
functionName = "";
funcArgList = new List<string>();
resultMessage = string.Empty;
var match = Regex.Match(input, @"^(\w+)\((.*?)\)$");
if (match.Success)
{
functionName = match.Groups[1].Value;
var args = match.Groups[2].Value;
if (!string.IsNullOrWhiteSpace(args))
{
funcArgList.AddRange(args.Split(','));
}
return true;
}
resultMessage = $"シグネチャ形式が不正です。[シグネチャ:{input}]";
return false;
}
}
}
+47
View File
@@ -0,0 +1,47 @@
using DocumentFormat.OpenXml.Math;
using KssSmaPlaLib.AutoTest.Command.Alias;
using KssSmaPlaLib.AutoTest.Script.Models;
using KssSmaPlaLib.AutoTest.Script.Parse.Function;
using System.Linq;
using System.Reflection;
namespace KssSmaPlaLib.AutoTest.Script.Parse
{
public static class ParseTryUxer
{
public static bool TryParse(StepDTO raw, out ParsedStepDTO parsed, out string resultMessage)
{
resultMessage = string.Empty;
parsed = new ParsedStepDTO(raw); // Raw注入
// ステップNo
if (string.IsNullOrEmpty(raw.StepNo))
{
resultMessage = $"UIテストステップ:ステップ番号が指定されていません。";
return false;
}
// ステップ情報:シグネチャのバリデーション
if (!FunctionTryUxer.TryFunction(raw.StepText, out var functionName, out var argList, out var messageForMe))
{
resultMessage = $"UIテストステップ:ステップ情報のシグネチャの変換に失敗しました。[エラー内容:{messageForMe}]";
return false;
}
// 関数(機能)名
if (!CommandAliasUxer.TryTranslate(functionName, out var commandEnum))
{
resultMessage = $"UIテストステップ:ステップ情報の関数(機能)名が未登録です。[関数(機能)名:{functionName}]";
return false;
}
// コマンド(enum値)
parsed.Command = commandEnum;
// パラメータ
parsed.Parameters = argList;
return true;
}
}
}
@@ -0,0 +1,16 @@
using KssSmaPlaLib.AutoTest.Script.Models;
namespace KssSmaPlaLib.AutoTest.Script.Storage
{
public static class TestScriptStorageUxer
{
private static StepInfoDTO _stepInfo = null;
public static StepInfoDTO StepInfo { get { return _stepInfo; } }
public static void SetStepInfo(StepInfoDTO stepInfo)
{
_stepInfo = stepInfo;
}
}
}