FileSystemWatcherTest.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // FileSystemWatcherTest.cs - NUnit Test Cases for the System.IO.FileSystemWatcher class
  2. //
  3. // Authors:
  4. // Gonzalo Paniagua Javier ([email protected])
  5. //
  6. // (C) 2004 Novell, Inc. http://www.novell.com
  7. //
  8. using NUnit.Framework;
  9. using System;
  10. using System.IO;
  11. namespace MonoTests.System.IO
  12. {
  13. [TestFixture]
  14. public class FileSystemWatcherTest : Assertion
  15. {
  16. [Test]
  17. public void CheckDefaults ()
  18. {
  19. FileSystemWatcher fw = new FileSystemWatcher ();
  20. AssertEquals ("#01", fw.EnableRaisingEvents, false);
  21. AssertEquals ("#02", fw.Filter, "*.*");
  22. AssertEquals ("#03", fw.IncludeSubdirectories, false);
  23. AssertEquals ("#04", fw.InternalBufferSize, 8192);
  24. AssertEquals ("#05", fw.NotifyFilter, NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite);
  25. AssertEquals ("#06", fw.Path, "");
  26. }
  27. [Test]
  28. [ExpectedException (typeof (ArgumentNullException))]
  29. public void CheckCtor1 ()
  30. {
  31. FileSystemWatcher fw = new FileSystemWatcher (null);
  32. }
  33. [Test]
  34. [ExpectedException (typeof (ArgumentException))]
  35. public void CheckCtor2 ()
  36. {
  37. FileSystemWatcher fw = new FileSystemWatcher ("");
  38. }
  39. [Test]
  40. [ExpectedException (typeof (ArgumentException))]
  41. public void CheckCtor3 ()
  42. {
  43. FileSystemWatcher fw = new FileSystemWatcher ("notexistsblahblah");
  44. }
  45. [Test]
  46. [ExpectedException (typeof (ArgumentNullException))]
  47. public void CheckCtor4 ()
  48. {
  49. FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), null);
  50. }
  51. [Test]
  52. // Doesn't throw here :-?
  53. // [ExpectedException (typeof (ArgumentException))]
  54. public void CheckCtor5 ()
  55. {
  56. FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), "invalidpath|");
  57. fw = new FileSystemWatcher (Path.GetTempPath (), "*");
  58. }
  59. [Test]
  60. // ...But here it does...
  61. [ExpectedException (typeof (ArgumentException))]
  62. public void CheckInvalidPath ()
  63. {
  64. FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), "invalidpath|");
  65. fw.Path = "invalidpath|";
  66. }
  67. [Test]
  68. // ...and here too
  69. [ExpectedException (typeof (ArgumentException))]
  70. public void CheckPathWildcard ()
  71. {
  72. FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), "*");
  73. fw.Path = "*";
  74. }
  75. }
  76. }