1 // Copyright 2004-2007 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
.Validator
.Tests
.ValidatorTests
17 using System
.Globalization
;
18 using System
.Threading
;
19 using NUnit
.Framework
;
22 public class GroupNotEmptyValidatorTestCase
24 private GroupNotEmptyValidator validator
;
25 private TestTarget target
;
30 Thread
.CurrentThread
.CurrentCulture
=
31 Thread
.CurrentThread
.CurrentUICulture
= new CultureInfo("en-us");
33 validator
= new GroupNotEmptyValidator("Dummy");
34 validator
.Initialize(typeof(TestTarget
).GetProperty("Foo"));
35 validator
.FriendlyName
= "BAR";
36 validator
.Initialize(typeof(TestTarget
).GetProperty("Bar"));
37 target
= new TestTarget();
41 public void BothEmptyStrings()
45 Assert
.IsFalse(validator
.IsValid(target
));
49 public void BothNonEmptyStrings()
53 Assert
.IsTrue(validator
.IsValid(target
));
57 public void FirstEmptySecondFull()
61 Assert
.IsTrue(validator
.IsValid(target
));
66 public void FirstFullSecondEmpty()
70 Assert
.IsTrue(validator
.IsValid(target
));
74 public void ErrorMessage()
76 Assert
.IsFalse(validator
.IsValid(target
));
79 "At least one of the values in (Foo, BAR) should not be empty"== validator
.ErrorMessage
80 || "At least one of the values in (BAR, Foo) should not be empty" == validator
.ErrorMessage
);
84 public class TestTarget