ClientAuthenticationTest.cs 1.7 KB

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