You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

  1. using OT.COM.LogisticsUtil;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Xunit;
  8. namespace TestUnit.OT.COM.LogisticsUtil
  9. {
  10. public class Test_CmdHelper
  11. {
  12. [Theory]
  13. [InlineData("ipconfig", "DNS")]
  14. public void ProcessCmd(string i_sProcessName, string i_sExpect)
  15. {
  16. string sCmd = CmdHelper.ProcessCmd(i_sProcessName, null);
  17. Assert.True(sCmd.Contains(i_sExpect), $"No expect wording '{i_sExpect}' in '{sCmd}'" );
  18. }
  19. [Theory]
  20. [InlineData("ipconfig", "DNS", null)]
  21. [InlineData("pl", null, "系統找不到指定的檔案")]
  22. public void ProcessCmdEx(string i_sProcessName, string i_sExpect , string i_sErrorExpect)
  23. {
  24. string sCmd = CmdHelper.ProcessCmdEx(i_sProcessName, null, out string sError);
  25. if (!string.IsNullOrEmpty(sError))
  26. {
  27. Assert.True(sError.Contains(i_sErrorExpect), $"No expect wording '{i_sErrorExpect}' in '{sError}'");
  28. }
  29. else
  30. {
  31. Assert.True(sCmd.Contains(i_sExpect), $"No expect wording '{i_sExpect}' in '{sCmd}'");
  32. }
  33. }
  34. }
  35. }