using OT.COM.LogisticsUtil; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xunit; namespace TestUnit.OT.COM.LogisticsUtil { public class Test_CmdHelper { [Theory] [InlineData("ipconfig", "DNS")] public void ProcessCmd(string i_sProcessName, string i_sExpect) { string sCmd = CmdHelper.ProcessCmd(i_sProcessName, null); Assert.True(sCmd.Contains(i_sExpect), $"No expect wording '{i_sExpect}' in '{sCmd}'" ); } [Theory] [InlineData("ipconfig", "DNS", null)] [InlineData("pl", null, "系統找不到指定的檔案")] public void ProcessCmdEx(string i_sProcessName, string i_sExpect , string i_sErrorExpect) { string sCmd = CmdHelper.ProcessCmdEx(i_sProcessName, null, out string sError); if (!string.IsNullOrEmpty(sError)) { Assert.True(sError.Contains(i_sErrorExpect), $"No expect wording '{i_sErrorExpect}' in '{sError}'"); } else { Assert.True(sCmd.Contains(i_sExpect), $"No expect wording '{i_sExpect}' in '{sCmd}'"); } } } }