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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Pedro MartÃnez Juliá <pedromj@gmail.com>
28 using NUnit.Framework;
31 using System.Windows.Forms;
32 using System.ComponentModel;
33 using System.Collections;
34 using System.Globalization;
35 using System.Threading;
37 namespace MonoTests.System.Windows.Forms {
40 public class DataGridViewCellStyleTest : TestHelper {
42 DataGridViewCellStyle style;
45 protected override void SetUp () {
46 style = new DataGridViewCellStyle();
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");
66 public void TestApplyStyle () {
67 DataGridViewCellStyle style_aux = new DataGridViewCellStyle();
68 style.ApplyStyle(style_aux);
69 Assert.AreEqual (style_aux, style, "#B1");
73 public void TestClone () {
74 DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
75 Assert.AreEqual (style_aux, style, "#C1");
79 public void TestEquals () {
80 DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
81 Assert.AreEqual (true, (style_aux.Equals(style)), "#D1");
85 [ExpectedException(typeof(InvalidEnumArgumentException))]
86 public void TestAlignmentInvalidEnumArgumentException () {
87 style.Alignment = DataGridViewContentAlignment.BottomCenter | DataGridViewContentAlignment.BottomRight;
91 [ExpectedException(typeof(InvalidEnumArgumentException))]
92 public void TestWrapModeInvalidEnumArgumentException () {
93 style.WrapMode = (DataGridViewTriState) 3;
97 public void FormatProvider ()
99 CultureInfo orignalCulture = CultureInfo.CurrentCulture;
100 CultureInfo orignalUICulture = CultureInfo.CurrentUICulture;
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");
115 Thread.CurrentThread.CurrentCulture = orignalCulture;
116 Thread.CurrentThread.CurrentUICulture = orignalUICulture;
121 public void IsFormatProviderDefault ()
123 CultureInfo orignalCulture = CultureInfo.CurrentCulture;
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");
138 Thread.CurrentThread.CurrentCulture = orignalCulture;