[System] Implement a helper function to create unique temporary directories and use...
[mono-project.git] / mcs / class / System / Test / System.IO / FileSystemWatcherTest.cs
blob585c15bcf7720127230e45ee4318855ea0d7a6ee
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 //
9 #if !MOBILE
11 using NUnit.Framework;
12 using System;
13 using System.IO;
15 using MonoTests.Helpers;
17 namespace MonoTests.System.IO
19 [TestFixture]
20 public class FileSystemWatcherTest
22 [Test]
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");
34 [Test]
35 [ExpectedException (typeof (ArgumentNullException))]
36 public void CheckCtor1 ()
38 FileSystemWatcher fw = new FileSystemWatcher (null);
41 [Test]
42 [ExpectedException (typeof (ArgumentException))]
43 public void CheckCtor2 ()
45 FileSystemWatcher fw = new FileSystemWatcher ("");
48 [Test]
49 [ExpectedException (typeof (ArgumentException))]
50 public void CheckCtor3 ()
52 FileSystemWatcher fw = new FileSystemWatcher ("notexistsblahblah");
55 [Test]
56 [ExpectedException (typeof (ArgumentNullException))]
57 public void CheckCtor4 ()
59 using (var tmp = new TempDirectory ()) {
60 FileSystemWatcher fw = new FileSystemWatcher (tmp.Path, null);
64 [Test]
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, "*");
77 [Test]
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|";
88 [Test]
89 // ...and here too
90 [ExpectedException (typeof (ArgumentException))]
91 public void CheckPathWildcard ()
93 using (var tmp = new TempDirectory ()) {
94 FileSystemWatcher fw = new FileSystemWatcher (tmp.Path, "*");
95 fw.Path = "*";
101 #endif