3 // Marek Habersack <mhabersack@novell.com>
5 // Copyright (C) 2010 Novell, Inc (http://novell.com)
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 using System.ComponentModel;
29 using NUnit.Framework;
31 namespace MonoTests.System.ComponentModel
34 public class MultilineStringConverterTest
37 public void GetPropertiesSupported ()
39 var cvt = new MultilineStringConverter ();
41 Assert.IsFalse (cvt.GetPropertiesSupported (), "#A1-1");
42 Assert.IsFalse (cvt.GetPropertiesSupported (null), "#A1-2");
46 public void GetProperties ()
48 var cvt = new MultilineStringConverter ();
50 Assert.IsNull (cvt.GetProperties (null, null, null), "#A1-1");
51 Assert.IsNull (cvt.GetProperties (null, "string", null), "#A1-2");
52 Assert.IsNull (cvt.GetProperties (null, "string", new Attribute[] {}), "#A1-1");
56 public void ConvertTo ()
58 var cvt = new MultilineStringConverter ();
60 AssertThrows<ArgumentNullException> (() => {
61 cvt.ConvertTo (null, null, "string", null);
64 AssertThrows<NotSupportedException> (() => {
65 cvt.ConvertTo (null, null, "string", typeof (int));
68 AssertThrows<NotSupportedException> (() => {
69 cvt.ConvertTo (null, null, "string", typeof (double));
72 object result = cvt.ConvertTo (null, null, "string", typeof (string));
73 Assert.IsNotNull (result, "#A2-1");
74 Assert.IsTrue (result.GetType () == typeof (string), "#A2-2");
75 Assert.AreEqual ("(Text)", (string) result, "#A2-3");
82 result = cvt.ConvertTo (null, null, orig, typeof (string));
83 Assert.IsNotNull (result, "#A3-1");
84 Assert.IsTrue (result.GetType () == typeof (string), "#A3-2");
85 Assert.AreEqual ("(Text)", (string) result, "#A3-3");
87 result = cvt.ConvertTo (null, null, 1234, typeof (string));
88 Assert.IsNotNull (result, "#A4-1");
89 Assert.IsTrue (result.GetType () == typeof (string), "#A4-2");
90 Assert.AreEqual ("1234", (string) result, "#A4-3");
93 void AssertThrows <ExType> (Action code, string format, params object [] parms) where ExType : Exception
96 throw new ArgumentNullException ("code");
103 } catch (Exception) {
108 Assert.Fail (format, parms);