MainTest.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using NUnit.Framework;
  2. using winsw;
  3. using winswTests.Util;
  4. namespace winswTests
  5. {
  6. [TestFixture]
  7. class MainTest
  8. {
  9. [Test]
  10. public void PrintVersion()
  11. {
  12. string expectedVersion = WrapperService.Version.ToString();
  13. string cliOut = CLITestHelper.CLITest(new[] { "version" });
  14. StringAssert.Contains(expectedVersion, cliOut, "Expected that version contains " + expectedVersion);
  15. }
  16. [Test]
  17. public void PrintHelp()
  18. {
  19. string expectedVersion = WrapperService.Version.ToString();
  20. string cliOut = CLITestHelper.CLITest(new[] { "help" });
  21. StringAssert.Contains(expectedVersion, cliOut, "Expected that help contains " + expectedVersion);
  22. StringAssert.Contains("start", cliOut, "Expected that help refers start command");
  23. StringAssert.Contains("help", cliOut, "Expected that help refers help command");
  24. StringAssert.Contains("version", cliOut, "Expected that help refers version command");
  25. //TODO: check all commands after the migration of ccommands to enum
  26. // Extra options
  27. StringAssert.Contains("/redirect", cliOut, "Expected that help message refers the redirect message");
  28. }
  29. [Test]
  30. public void FailOnUnsupportedCommand()
  31. {
  32. const string commandName = "nonExistentCommand";
  33. string expectedMessage = "Unknown command: " + commandName.ToLower();
  34. CLITestResult res = CLITestHelper.CLIErrorTest(new[] {commandName});
  35. Assert.True(res.HasException, "Expected an exception due to the wrong command");
  36. StringAssert.Contains(expectedMessage, res.Out, "Expected the message about unknown command");
  37. // ReSharper disable once PossibleNullReferenceException
  38. StringAssert.Contains(expectedMessage, res.Exception.Message, "Expected the message about unknown command");
  39. }
  40. }
  41. }