Mercurial > pub > bltoolkit
diff UnitTests/CS/Validation/NullValue.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UnitTests/CS/Validation/NullValue.cs Thu Mar 27 21:46:09 2014 +0400 @@ -0,0 +1,56 @@ +using System; +using BLToolkit.EditableObjects; +using BLToolkit.Reflection; +using NUnit.Framework; + +using BLToolkit.Validation; +using BLToolkit.Mapping; + +namespace Validation +{ + [TestFixture] + public class NullValue + { + public class Entity : EditableObject + { + private byte timeStart; + + [Required("Time Start is required")] + [NullValue(typeof(byte), 99)] + public byte TimeStart + { + get { return timeStart; } + set { timeStart = value; } + } + } + + [Test] + public void Test() + { + Entity test = new Entity(); + + test.TimeStart = 0; + test.Validate(); + } + + public abstract class PersonDoc : EditableObject + { + [MapField("Series_PersonDoc"), MaxLength(50), Required] + public abstract string Series_PersonDoc { get; set; } + + [MapField("BegDate_PersonDoc"), Required] + [NullDateTime()] + public abstract DateTime BegDate_PersonDoc { get; set; } + } + + + [Test, ExpectedException(typeof(ValidationException))] + public void Test2() + { + PersonDoc doc = TypeAccessor<PersonDoc>.CreateInstance(); + + doc.Series_PersonDoc = "PersonDoc"; + doc.Validate(); + } + } +}