ClientAuthenticationTest.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using Moq;
  4. namespace Renci.SshNet.Tests.Classes
  5. {
  6. [TestClass]
  7. public class ClientAuthenticationTest
  8. {
  9. private ClientAuthentication _clientAuthentication;
  10. [TestInitialize]
  11. public void Init()
  12. {
  13. _clientAuthentication = new ClientAuthentication();
  14. }
  15. [TestMethod]
  16. public void AuthenticateShouldThrowArgumentNullExceptionWhenConnectionInfoIsNull()
  17. {
  18. IConnectionInfoInternal connectionInfo = null;
  19. var session = new Mock<ISession>(MockBehavior.Strict).Object;
  20. try
  21. {
  22. _clientAuthentication.Authenticate(connectionInfo, session);
  23. Assert.Fail();
  24. }
  25. catch (ArgumentNullException ex)
  26. {
  27. Assert.IsNull(ex.InnerException);
  28. Assert.AreEqual("connectionInfo", ex.ParamName);
  29. }
  30. }
  31. [TestMethod]
  32. public void AuthenticateShouldThrowArgumentNullExceptionWhenSessionIsNull()
  33. {
  34. var connectionInfo = new Mock<IConnectionInfoInternal>(MockBehavior.Strict).Object;
  35. ISession session = null;
  36. try
  37. {
  38. _clientAuthentication.Authenticate(connectionInfo, session);
  39. Assert.Fail();
  40. }
  41. catch (ArgumentNullException ex)
  42. {
  43. Assert.IsNull(ex.InnerException);
  44. Assert.AreEqual("session", ex.ParamName);
  45. }
  46. }
  47. }
  48. }