1 // FileSystemWatcherTest.cs - NUnit Test Cases for the System.IO.FileSystemWatcher class
4 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 // (C) 2004 Novell, Inc. http://www.novell.com
11 using NUnit
.Framework
;
15 using MonoTests
.Helpers
;
17 namespace MonoTests
.System
.IO
20 public class FileSystemWatcherTest
23 public void CheckDefaults ()
25 FileSystemWatcher fw
= new FileSystemWatcher ();
26 Assert
.AreEqual (fw
.EnableRaisingEvents
, false, "#01");
27 Assert
.AreEqual (fw
.Filter
, "*", "#02");
28 Assert
.AreEqual (fw
.IncludeSubdirectories
, false, "#03");
29 Assert
.AreEqual (fw
.InternalBufferSize
, 8192, "#04");
30 Assert
.AreEqual (fw
.NotifyFilter
, NotifyFilters
.FileName
| NotifyFilters
.DirectoryName
| NotifyFilters
.LastWrite
, "#05");
31 Assert
.AreEqual (fw
.Path
, "", "#06");
35 [ExpectedException (typeof (ArgumentNullException
))]
36 public void CheckCtor1 ()
38 FileSystemWatcher fw
= new FileSystemWatcher (null);
42 [ExpectedException (typeof (ArgumentException
))]
43 public void CheckCtor2 ()
45 FileSystemWatcher fw
= new FileSystemWatcher ("");
49 [ExpectedException (typeof (ArgumentException
))]
50 public void CheckCtor3 ()
52 FileSystemWatcher fw
= new FileSystemWatcher ("notexistsblahblah");
56 [ExpectedException (typeof (ArgumentNullException
))]
57 public void CheckCtor4 ()
59 using (var tmp
= new TempDirectory ()) {
60 FileSystemWatcher fw
= new FileSystemWatcher (tmp
.Path
, null);
65 // Doesn't throw here :-?
66 // [ExpectedException (typeof (ArgumentException))]
67 public void CheckCtor5 ()
69 using (var tmp1
= new TempDirectory ()) {
70 using (var tmp2
= new TempDirectory ()) {
71 FileSystemWatcher fw
= new FileSystemWatcher (tmp1
.Path
, "invalidpath|");
72 fw
= new FileSystemWatcher (tmp2
.Path
, "*");
78 // ...But here it does...
79 [ExpectedException (typeof (ArgumentException
))]
80 public void CheckInvalidPath ()
82 using (var tmp
= new TempDirectory ()) {
83 FileSystemWatcher fw
= new FileSystemWatcher (tmp
.Path
, "invalidpath|");
84 fw
.Path
= "invalidpath|";
90 [ExpectedException (typeof (ArgumentException
))]
91 public void CheckPathWildcard ()
93 using (var tmp
= new TempDirectory ()) {
94 FileSystemWatcher fw
= new FileSystemWatcher (tmp
.Path
, "*");