2009-06-06 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / FolderBrowserDialogTest.cs
1 //
2 // FolderBrowserDialogTest.cs: Test cases for FolderBrowserDialog.
3 //
4 // Author:
5 //      Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // (C) 2007 Gert Driesen
8 //
9
10 using System;
11 using System.ComponentModel;
12 using System.Windows.Forms;
13
14 using NUnit.Framework;
15
16 namespace MonoTests.System.Windows.Forms
17 {
18         [TestFixture]
19         public class FolderBrowserDialogTest : TestHelper
20         {
21                 [Test]
22                 public void Description ()
23                 {
24                         FolderBrowserDialog fbd = new FolderBrowserDialog ();
25                         Assert.AreEqual (string.Empty, fbd.Description, "#1");
26                         fbd.Description = null;
27                         Assert.AreEqual (string.Empty, fbd.Description, "#2");
28                         fbd.Description = "Select a folder";
29                         Assert.AreEqual ("Select a folder", fbd.Description, "#3");
30                         fbd.Description = null;
31                         Assert.AreEqual (string.Empty, fbd.Description, "#4");
32                 }
33
34                 [Test]
35                 public void SelectedPath ()
36                 {
37                         FolderBrowserDialog fbd = new FolderBrowserDialog ();
38                         Assert.AreEqual (string.Empty, fbd.SelectedPath, "#1");
39                         fbd.SelectedPath = null;
40                         Assert.AreEqual (string.Empty, fbd.SelectedPath, "#2");
41                         fbd.SelectedPath = "{}###()";
42                         Assert.AreEqual ("{}###()", fbd.SelectedPath, "#3");
43                         fbd.SelectedPath = null;
44                         Assert.AreEqual (string.Empty, fbd.SelectedPath, "#4");
45                 }
46
47                 [Test]
48                 public void ShowNewFolderButton ()
49                 {
50                         FolderBrowserDialog fbd = new FolderBrowserDialog ();
51                         Assert.IsTrue (fbd.ShowNewFolderButton, "#1");
52                         fbd.ShowNewFolderButton = false;
53                         Assert.IsFalse (fbd.ShowNewFolderButton, "#2");
54                         fbd.ShowNewFolderButton = true;
55                         Assert.IsTrue (fbd.ShowNewFolderButton, "#3");
56                 }
57
58                 [Test]
59                 public void RootFolder ()
60                 {
61                         FolderBrowserDialog fbd = new FolderBrowserDialog ();
62                         Assert.AreEqual (Environment.SpecialFolder.Desktop, fbd.RootFolder, "#1");
63                         fbd.RootFolder = Environment.SpecialFolder.Personal;
64                         Assert.AreEqual (Environment.SpecialFolder.Personal, fbd.RootFolder, "#2");
65                 }
66
67                 [Test]
68                 public void RootFolder_Invalid ()
69                 {
70                         FolderBrowserDialog fbd = new FolderBrowserDialog ();
71                         try {
72                                 fbd.RootFolder = (Environment.SpecialFolder) 666;
73                                 Assert.Fail ("#1");
74                         } catch (InvalidEnumArgumentException ex) {
75                                 Assert.AreEqual (typeof (InvalidEnumArgumentException), ex.GetType (), "#2");
76                                 Assert.IsNull (ex.InnerException, "#3");
77                                 Assert.IsNotNull (ex.Message, "#4");
78                                 Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#5");
79                                 Assert.IsTrue (ex.Message.IndexOf ("SpecialFolder") != -1, "#6");
80                                 Assert.IsNotNull (ex.ParamName, "#7");
81                                 Assert.AreEqual ("value", ex.ParamName, "#8");
82                         }
83                 }
84         }
85 }