1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Components
.Binder
.Tests
18 using System
.Globalization
;
19 using System
.Threading
;
21 using NUnit
.Framework
;
24 public class NullablesTestCase
26 private bool convSucceed
;
31 CultureInfo en
= CultureInfo
.CreateSpecificCulture( "en" );
33 Thread
.CurrentThread
.CurrentCulture
= en
;
34 Thread
.CurrentThread
.CurrentUICulture
= en
;
38 public void NullableIntConversion()
40 Assert
.AreEqual(new NullableInt32(10), Convert(typeof(NullableInt32
), "10"));
41 Assert
.IsTrue(convSucceed
);
43 NullableInt32 val
= (NullableInt32
) Convert(typeof(NullableInt32
), "");
44 Assert
.IsFalse(val
.HasValue
);
45 Assert
.IsTrue(convSucceed
);
48 private object Convert(Type desiredType
, string input
)
50 return new DefaultConverter().Convert(desiredType
, input
, out convSucceed
);