2006-12-19 Daniel Nauck <dna@mono-project.de>
[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 #if NET_2_0
28
29 using NUnit.Framework;
30 using System;
31 using System.Drawing;
32 using System.Windows.Forms;
33 using System.ComponentModel;
34 using System.Collections;
35 using System.Globalization;
36
37 namespace MonoTests.System.Windows.Forms {
38
39         [TestFixture]
40         public class DataGridViewCellStyleTest {
41
42                 DataGridViewCellStyle style;
43                 
44                 [SetUp]
45                 public void GetReady() {
46                         style = new DataGridViewCellStyle();
47                 }
48
49                 [TearDown]
50                 public void Clean() {
51                         style = new DataGridViewCellStyle();
52                 }
53
54                 [Test]
55                 public void TestDefaultValues () {
56                         Assert.AreEqual (DataGridViewContentAlignment.NotSet, style.Alignment, "#A1");
57                         Assert.AreEqual (Color.Empty, style.BackColor, "#A2");
58                         Assert.AreEqual (null, style.Font, "#A3");
59                         Assert.AreEqual (Color.Empty, style.ForeColor, "#A4");
60                         Assert.AreEqual (String.Empty, style.Format, "#A5");
61                         Assert.AreEqual (CultureInfo.CurrentUICulture, style.FormatProvider, "#A6");
62                         Assert.AreEqual (true, style.IsFormatProviderDefault, "#A7");
63                         Assert.AreEqual (true, style.IsNullValueDefault, "#A8");
64                         Assert.AreEqual (string.Empty, style.NullValue, "#A9");
65                         Assert.AreEqual (Color.Empty, style.SelectionBackColor, "#A10");
66                         Assert.AreEqual (Color.Empty, style.SelectionForeColor, "#A11");
67                         Assert.AreEqual (null, style.Tag, "#A12");
68                         Assert.AreEqual (DataGridViewTriState.NotSet, style.WrapMode, "#A13");
69                 }
70
71                 [Test]
72                 public void TestApplyStyle () {
73                         DataGridViewCellStyle style_aux = new DataGridViewCellStyle();
74                         style.ApplyStyle(style_aux);
75                         Assert.AreEqual (style_aux, style, "#B1");
76                 }
77
78                 [Test]
79                 public void TestClone () {
80                         DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
81                         Assert.AreEqual (style_aux, style, "#C1");
82                 }
83
84                 [Test]
85                 public void TestEquals () {
86                         DataGridViewCellStyle style_aux = (DataGridViewCellStyle) style.Clone();
87                         Assert.AreEqual (true, (style_aux.Equals(style)), "#D1");
88                 }
89
90                 [Test]
91                 [ExpectedException(typeof(InvalidEnumArgumentException))]
92                 public void TestAlignmentInvalidEnumArgumentException () {
93                         style.Alignment = DataGridViewContentAlignment.BottomCenter | DataGridViewContentAlignment.BottomRight;
94                 }
95
96                 [Test]
97                 [ExpectedException(typeof(InvalidEnumArgumentException))]
98                 public void TestWrapModeInvalidEnumArgumentException () {
99                         style.WrapMode = (DataGridViewTriState) 3;
100                 }
101         }
102 }
103
104 #endif