[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System / Test / System.ComponentModel.Design / CheckoutExceptionTest.cs
1 //
2 // CheckoutExceptionTest.cs - NUnit tests for CheckoutException
3 //
4 // Author:
5 //      Gert Driesen  <drieseng@users.sourceforge.net>
6 //
7 // Copyright (C) 2007 Gert Driesen
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 #if !MOBILE
30
31 using System;
32 using System.ComponentModel.Design;
33 using System.Runtime.InteropServices;
34
35 using NUnit.Framework;
36
37 namespace MonoTests.System.ComponentModel.Design
38 {
39         [TestFixture]
40         public class CheckoutExceptionTest
41         {
42                 [Test] // ctor ()
43                 public void Constructor0 ()
44                 {
45                         CheckoutException ex = new CheckoutException ();
46                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#1");
47                         Assert.IsNull (ex.InnerException, "#2");
48                         Assert.IsNotNull (ex.Message, "#3");
49                         Assert.IsTrue (ex.Message.IndexOf (ex.GetType ().FullName) == -1, "#4");
50                         Assert.AreEqual (new ExternalException ().Message, ex.Message, "#5");
51                 }
52
53                 [Test] // ctor (string)
54                 public void Constructor1 ()
55                 {
56                         CheckoutException ex;
57                         string msg = "ERROR";
58
59                         ex = new CheckoutException (msg);
60                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#A1");
61                         Assert.IsNull (ex.InnerException, "#A2");
62                         Assert.AreSame (msg, ex.Message, "#A3");
63
64                         ex = new CheckoutException ((string) null);
65                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#B1");
66                         Assert.IsNull (ex.InnerException, "#B2");
67                         Assert.IsNotNull (msg, ex.Message, "#B3");
68                         Assert.IsTrue (ex.Message.IndexOf (ex.GetType ().FullName) != -1, "#B4");
69
70                         ex = new CheckoutException (string.Empty);
71                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#C1");
72                         Assert.IsNull (ex.InnerException, "#C2");
73                         Assert.IsNotNull (msg, ex.Message, "#C3");
74                         Assert.AreEqual (string.Empty, ex.Message, "#C4");
75                 }
76
77                 [Test] // ctor (string, Exception)
78                 public void Constructor3 ()
79                 {
80                         CheckoutException ex;
81                         string msg = "ERROR";
82                         Exception inner = new Exception ();
83
84                         ex = new CheckoutException (msg, inner);
85                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#A1");
86                         Assert.AreSame (inner, ex.InnerException, "#A2");
87                         Assert.AreSame (msg, ex.Message, "#A3");
88
89                         ex = new CheckoutException ((string) null, inner);
90                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#B1");
91                         Assert.AreSame (inner, ex.InnerException, "#B2");
92                         Assert.IsNotNull (msg, ex.Message, "#B3");
93                         Assert.AreEqual (new CheckoutException (null).Message, ex.Message, "#B4");
94
95                         ex = new CheckoutException (msg, (Exception) null);
96                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#C1");
97                         Assert.IsNull (ex.InnerException, "#C2");
98                         Assert.AreSame (msg, ex.Message, "#C3");
99
100                         ex = new CheckoutException (string.Empty, (Exception) null);
101                         Assert.AreEqual (-2147467259, ex.ErrorCode, "#D1");
102                         Assert.IsNull (ex.InnerException, "#D2");
103                         Assert.IsNotNull (ex.Message, "#D3");
104                         Assert.AreEqual (string.Empty, ex.Message, "#D4");
105                 }
106
107                 [Test] // ctor (string, int)
108                 public void Constructor4 ()
109                 {
110                         CheckoutException ex;
111                         string msg = "ERROR";
112
113                         ex = new CheckoutException (msg, int.MinValue);
114                         Assert.AreEqual (int.MinValue, ex.ErrorCode, "#A1");
115                         Assert.IsNull (ex.InnerException, "#A2");
116                         Assert.AreSame (msg, ex.Message, "#A3");
117
118                         ex = new CheckoutException ((string) null, int.MaxValue);
119                         Assert.AreEqual (int.MaxValue, ex.ErrorCode, "#B1");
120                         Assert.IsNull (ex.InnerException, "#B2");
121                         Assert.IsNotNull (msg, ex.Message, "#B3");
122                         Assert.AreEqual (new CheckoutException (null).Message, ex.Message, "#B4");
123
124                         ex = new CheckoutException (msg, 0);
125                         Assert.AreEqual (0, ex.ErrorCode, "#C1");
126                         Assert.IsNull (ex.InnerException, "#C2");
127                         Assert.AreSame (msg, ex.Message, "#C3");
128
129                         ex = new CheckoutException (string.Empty, 0);
130                         Assert.AreEqual (0, ex.ErrorCode, "#D1");
131                         Assert.IsNull (ex.InnerException, "#D2");
132                         Assert.IsNotNull (ex.Message, "#D3");
133                         Assert.AreEqual (string.Empty, ex.Message, "#D4");
134                 }
135
136                 [Test]
137                 public void Canceled ()
138                 {
139                         CheckoutException ex = CheckoutException.Canceled;
140                         Assert.AreEqual (-2147467260, ex.ErrorCode, "#1");
141                         Assert.IsNull (ex.InnerException, "#2");
142                         Assert.IsNotNull (ex.Message, "#3");
143                         Assert.IsTrue (ex.Message.IndexOf (ex.GetType ().FullName) == -1, "#4");
144                 }
145         }
146 }
147
148 #endif