Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Components / Validator / Castle.Components.Validator.Tests / ValidatorTests / NullableSingleValidatorTestCase.cs
blobc8a3e8cfb1dfbfb3f9ee59e4c3793459662b2913
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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.Validator.Tests.ValidatorTests
17 using System.Globalization;
18 using System.Threading;
19 using NUnit.Framework;
21 [TestFixture]
22 public class NullableSingleValidatorTestCase
24 private NullableSingleValidator validator;
25 private TestTarget target;
27 [SetUp]
28 public void Init()
30 Thread.CurrentThread.CurrentCulture =
31 Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
33 validator = new NullableSingleValidator();
34 validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));
35 target = new TestTarget();
38 [Test]
39 public void InvalidSingle()
41 Assert.IsFalse(validator.IsValid(target, "abc"));
44 [Test]
45 public void ValidSingle()
47 Assert.IsTrue(validator.IsValid(target, "100"));
48 Assert.IsTrue(validator.IsValid(target, "100.11002"));
49 Assert.IsTrue(validator.IsValid(target, "-99.8"));
50 Assert.IsTrue(validator.IsValid(target, "-99"));
51 Assert.IsTrue(validator.IsValid(target, null));
52 Assert.IsTrue(validator.IsValid(target, ""));
55 public class TestTarget
57 private double targetField;
59 public double TargetField
61 get { return targetField; }
62 set { targetField = value; }