[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / DataGridViewCellStyleTest.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Author:
23 //      Pedro Martínez Juliá <pedromj@gmail.com>
24 //
25
26
27
28 using NUnit.Framework;
29 using System;
30 using System.Drawing;
31 using System.Windows.Forms;
32 using System.ComponentModel;
33 using System.Collections;
34 using System.Globalization;
35 using System.Threading;
36
37 namespace MonoTests.System.Windows.Forms {
38
39         [TestFixture]
40         public class DataGridViewCellStyleTest  : TestHelper {
41
42                 DataGridViewCellStyle style;
43                 
44                 [SetUp]
45                 protected override void SetUp () {
46                         style = new DataGridViewCellStyle();
47                         base.SetUp ();
48                 }
49
50                 [Test]
51                 public void TestDefaultValues () {
52                         Assert.AreEqual (DataGridViewContentAlignment.NotSet, style.Alignment, "#A1");
53                         Assert.AreEqual (Color.Empty, style.BackColor, "#A2");
54                         Assert.AreEqual (null, style.Font, "#A3");
55                         Assert.AreEqual (Color.Empty, style.ForeColor, "#A4");
56                         Assert.AreEqual (String.Empty, style.Format, "#A5");
57                         Assert.AreEqual (true, style.IsNullValueDefault, "#A8");
58                         Assert.AreEqual (string.Empty, style.NullValue, "#A9");
59                         Assert.AreEqual (Color.Empty, style.SelectionBackColor, "#A10");
60                         Assert.AreEqual (Color.Empty, style.SelectionForeColor, "#A11");
61                         Assert.AreEqual (null, style.Tag, "#A12");
62                         Assert.AreEqual (DataGridViewTriState.NotSet, style.WrapMode, "#A13");
63                 }
64
65                 [Test]
66                 public void TestApplyStyle () {
67                         DataGridViewCellStyle style_aux = new DataGridViewCellStyle();
68                         style.ApplyStyle(style_aux);
69                         Assert.AreEqual (style_aux, style, "#B1");
70                 }
71
72                 [Test]
73                 public void TestClone () {
74                         DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
75                         Assert.AreEqual (style_aux, style, "#C1");
76                 }
77
78                 [Test]
79                 public void TestEquals () {
80                         DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
81                         Assert.AreEqual (true, (style_aux.Equals(style)), "#D1");
82                 }
83
84                 [Test]
85                 [ExpectedException(typeof(InvalidEnumArgumentException))]
86                 public void TestAlignmentInvalidEnumArgumentException () {
87                         style.Alignment = DataGridViewContentAlignment.BottomCenter | DataGridViewContentAlignment.BottomRight;
88                 }
89
90                 [Test]
91                 [ExpectedException(typeof(InvalidEnumArgumentException))]
92                 public void TestWrapModeInvalidEnumArgumentException () {
93                         style.WrapMode = (DataGridViewTriState) 3;
94                 }
95
96                 [Test]
97                 public void FormatProvider ()
98                 {
99                         CultureInfo orignalCulture = CultureInfo.CurrentCulture;
100                         CultureInfo orignalUICulture = CultureInfo.CurrentUICulture;
101
102                         try {
103                                 Thread.CurrentThread.CurrentCulture = new CultureInfo ("nl-BE");
104                                 Thread.CurrentThread.CurrentUICulture = new CultureInfo ("ja-JP");
105                                 Assert.AreSame (CultureInfo.CurrentCulture, style.FormatProvider, "#1");
106                                 Thread.CurrentThread.CurrentCulture = new CultureInfo ("fr-FR");
107                                 Assert.AreSame (CultureInfo.CurrentCulture, style.FormatProvider, "#2");
108                                 style.FormatProvider = CultureInfo.CurrentCulture;
109                                 Assert.AreSame (CultureInfo.CurrentCulture, style.FormatProvider, "#3");
110                                 Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
111                                 Assert.AreEqual (new CultureInfo ("fr-FR"), style.FormatProvider, "#4");
112                                 style.FormatProvider = null;
113                                 Assert.AreSame (CultureInfo.CurrentCulture, style.FormatProvider, "#5");
114                         } finally {
115                                 Thread.CurrentThread.CurrentCulture = orignalCulture;
116                                 Thread.CurrentThread.CurrentUICulture = orignalUICulture;
117                         }
118                 }
119
120                 [Test]
121                 public void IsFormatProviderDefault ()
122                 {
123                         CultureInfo orignalCulture = CultureInfo.CurrentCulture;
124
125                         try {
126                                 Assert.IsTrue (style.IsFormatProviderDefault, "#1");
127                                 Thread.CurrentThread.CurrentCulture = new CultureInfo ("nl-BE");
128                                 Assert.IsTrue (style.IsFormatProviderDefault, "#2");
129                                 Thread.CurrentThread.CurrentCulture = new CultureInfo ("fr-FR");
130                                 Assert.IsTrue (style.IsFormatProviderDefault, "#3");
131                                 style.FormatProvider = CultureInfo.CurrentCulture;
132                                 Assert.IsFalse (style.IsFormatProviderDefault, "#4");
133                                 style.FormatProvider = new CultureInfo ("en-US");
134                                 Assert.IsFalse (style.IsFormatProviderDefault, "#5");
135                                 style.FormatProvider = null;
136                                 Assert.IsTrue (style.IsFormatProviderDefault, "#6");
137                         } finally {
138                                 Thread.CurrentThread.CurrentCulture = orignalCulture;
139                         }
140                 }
141         }
142 }
143