Reformatting the code according to castle guidelines.
[castle.git] / Components / General / Validator / Castle.Components.Validator.Tests / ValidatorTests / EmailValidatorTestCase.cs
blobe3270009f820d06c75f7796a404385748440236f
1 // Copyright 2004-2007 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 EmailValidatorTestCase
24 private EmailValidator 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 EmailValidator();
34 validator.Initialize(typeof(TestTarget).GetProperty("TargetField"));
35 target = new TestTarget();
38 [Test]
39 public void InvalidEmail()
41 Assert.IsFalse(validator.IsValid(target, "abc"));
42 Assert.IsFalse(validator.IsValid(target, "ham@ham@ham"));
45 [Test]
46 public void ValidEmail()
48 Assert.IsTrue(validator.IsValid(target, "hammett@gmail.com"));
49 Assert.IsTrue(validator.IsValid(target, "hammett@uol.com.br"));
50 Assert.IsTrue(validator.IsValid(target, "hammett@apache.org"));
51 Assert.IsTrue(validator.IsValid(target, "hamilton.verissimo@something.com.br"));
54 public class TestTarget
56 private string targetField;
58 public string TargetField
60 get { return targetField; }
61 set { targetField = value; }