67eb9b7e09393ebb67195d0288b269cae32b3993
[mono.git] / mcs / class / System / Test / System.ComponentModel / PropertyDescriptorTests.cs
1 //
2 // System.ComponentModel.PropertyDescriptor test cases
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (c) 2006 Novell, Inc. (http://www.novell.com/)
8 //
9
10 using System;
11 using System.Collections;
12 using System.ComponentModel;
13 using System.Globalization;
14
15 using NUnit.Framework;
16
17 namespace MonoTests.System.ComponentModel
18 {
19         [TestFixture]
20         public class PropertyDescriptorTests
21         {
22                 class ReadOnlyProperty_test
23                 {
24                         public int Prop {
25                                 get { return 5; }
26                         }
27                 }
28
29                 class ReadOnlyAttribute_test
30                 {
31                         [ReadOnly (true)]
32                         public int Prop {
33                                 get { return 5; }
34                                 set { }
35                         }
36                 }
37
38                 class ConflictingReadOnly_test
39                 {
40                         [ReadOnly (false)]
41                         public int Prop {
42                                 get { return 5; }
43                         }
44                 }
45
46                 [Test]
47                 public void ReadOnlyPropertyTest ()
48                 {
49                         PropertyDescriptorCollection col = TypeDescriptor.GetProperties (typeof (ReadOnlyProperty_test));
50                         Assert.IsTrue (col["Prop"].IsReadOnly, "1");
51                 }
52
53                 [Test]
54                 public void ReadOnlyAttributeTest ()
55                 {
56                         PropertyDescriptorCollection col = TypeDescriptor.GetProperties (typeof (ReadOnlyAttribute_test));
57                         Assert.IsTrue (col["Prop"].IsReadOnly, "1");
58                 }
59
60                 [Test]
61                 public void ReadOnlyConflictingTest ()
62                 {
63                         PropertyDescriptorCollection col = TypeDescriptor.GetProperties (typeof (ConflictingReadOnly_test));
64                         Assert.IsTrue (col["Prop"].IsReadOnly, "1");
65                 }
66         }
67 }