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