SmtpClientTest.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // SmtpClientTest.cs - NUnit Test Cases for System.Net.Mail.SmtpClient
  3. //
  4. // Authors:
  5. // John Luke ([email protected])
  6. //
  7. // (C) 2006 John Luke
  8. //
  9. #if NET_2_0
  10. using NUnit.Framework;
  11. using System;
  12. using System.IO;
  13. using System.Net.Mail;
  14. using System.Net.Mime;
  15. namespace MonoTests.System.Net.Mail
  16. {
  17. [TestFixture]
  18. public class SmtpClientTest
  19. {
  20. SmtpClient smtp;
  21. [SetUp]
  22. public void GetReady ()
  23. {
  24. smtp = new SmtpClient ();
  25. }
  26. [Test]
  27. public void InitialTimeout ()
  28. {
  29. Assert.AreEqual (smtp.Timeout, 100000);
  30. }
  31. [Test]
  32. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  33. public void NegativePortValue ()
  34. {
  35. smtp.Port = -1;
  36. }
  37. [Test]
  38. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  39. public void NegativeTimeoutValue ()
  40. {
  41. smtp.Timeout = -1;
  42. }
  43. [Test]
  44. [ExpectedException (typeof (ArgumentNullException))]
  45. public void NullHost ()
  46. {
  47. smtp.Host = null;
  48. }
  49. [Test]
  50. [ExpectedException (typeof (ArgumentException))]
  51. public void EmptyHost ()
  52. {
  53. smtp.Host = String.Empty;
  54. }
  55. [Test]
  56. [Category ("NotWorking")]
  57. public void Credentials_Default ()
  58. {
  59. Assert.IsNull (smtp.Credentials);
  60. }
  61. [Test]
  62. public void DeliveryMethod_Default ()
  63. {
  64. Assert.AreEqual (SmtpDeliveryMethod.Network, smtp.DeliveryMethod);
  65. }
  66. [Test]
  67. public void EnableSsl_Default ()
  68. {
  69. Assert.IsFalse (smtp.EnableSsl);
  70. }
  71. [Test]
  72. [Category ("NotWorking")]
  73. public void Host_Default ()
  74. {
  75. Assert.IsNull (smtp.Host);
  76. }
  77. [Test]
  78. public void PickupDirectoryLocation_Default ()
  79. {
  80. Assert.IsNull (smtp.PickupDirectoryLocation);
  81. }
  82. [Test]
  83. public void Port_Default ()
  84. {
  85. Assert.AreEqual (25, smtp.Port);
  86. }
  87. [Test]
  88. public void Timeout_Default ()
  89. {
  90. Assert.AreEqual (100000, smtp.Timeout);
  91. }
  92. [Test]
  93. public void UseDefaultCredentials_Default ()
  94. {
  95. Assert.IsFalse (smtp.UseDefaultCredentials);
  96. }
  97. }
  98. }
  99. #endif