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