NoneAuthenticationMethodTest.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Globalization;
  3. using Microsoft.VisualStudio.TestTools.UnitTesting;
  4. using Renci.SshNet.Tests.Common;
  5. namespace Renci.SshNet.Tests.Classes
  6. {
  7. /// <summary>
  8. /// Provides functionality for "none" authentication method
  9. /// </summary>
  10. [TestClass]
  11. public class NoneAuthenticationMethodTest : TestBase
  12. {
  13. [TestMethod]
  14. [TestCategory("AuthenticationMethod")]
  15. [Owner("Kenneth_aa")]
  16. [Description("NoneAuthenticationMethod: Pass null as username.")]
  17. [ExpectedException(typeof(ArgumentException))]
  18. public void None_Test_Pass_Null()
  19. {
  20. new NoneAuthenticationMethod(null);
  21. }
  22. [TestMethod]
  23. [TestCategory("AuthenticationMethod")]
  24. [Owner("Kenneth_aa")]
  25. [Description("NoneAuthenticationMethod: Pass String.Empty as username.")]
  26. [ExpectedException(typeof(ArgumentException))]
  27. public void None_Test_Pass_Whitespace()
  28. {
  29. new NoneAuthenticationMethod(string.Empty);
  30. }
  31. [TestMethod]
  32. public void Name()
  33. {
  34. var username = new Random().Next().ToString(CultureInfo.InvariantCulture);
  35. var target = new NoneAuthenticationMethod(username);
  36. Assert.AreEqual("none", target.Name);
  37. }
  38. [TestMethod]
  39. public void Username()
  40. {
  41. var username = new Random().Next().ToString(CultureInfo.InvariantCulture);
  42. var target = new NoneAuthenticationMethod(username);
  43. Assert.AreSame(username, target.Username);
  44. }
  45. }
  46. }