Added RedirectUsingNamedRoute
[castle.git] / Components / Validator / Castle.Components.Validator.Tests / ValidatorTests / NonEmptyValidatorTestCase.cs
blob0018035cc43c68eba8b4c16a3f7551460aee5c3a
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 NonEmptyValidatorTestCase
24 private NonEmptyValidator 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 NonEmptyValidator();
34 validator.Initialize(new CachedValidationRegistry(), typeof(TestTarget).GetProperty("TargetField"));
35 target = new TestTarget();
38 [Test]
39 public void EmptyStrings()
41 Assert.IsFalse(validator.IsValid(target, null));
42 Assert.IsFalse(validator.IsValid(target, ""));
45 [Test]
46 public void NonEmptyStrings()
48 Assert.IsTrue(validator.IsValid(target, "abc"));
49 Assert.IsTrue(validator.IsValid(target, " "));
52 public class TestTarget
54 private string targetField;
56 public string TargetField
58 get { return targetField; }
59 set { targetField = value; }