Business Logic Toolkit for .NET
www.bltoolkit.net
Welcome Guest, you are in: Login
|  Home   |  Download   |  Documentation   |  Discussions   |  Issues   |  License   |
RSS RSS

Navigation




Search the wiki
»

PoweredBy
InitialValues.cs

using System;

using NUnit.Framework;

using BLToolkit.Reflection; using BLToolkit.TypeBuilder;

namespace HowTo.TypeBuilder { [TestFixture] public class InitialValueTest { [AttributeUsage(AttributeTargets.Property)] public class NewGuidParameterAttribute : ParameterAttribute { public NewGuidParameterAttribute() : base(Guid.NewGuid().ToByteArray()) { } }

public abstract class TestObject1 { [Parameter("t")] public abstract string Str { get; set; } [Parameter(20)] public abstract string this[int i] { get; set; } [Parameter(54)] public abstract int Int { get; set; } [Parameter(2,2,2)] public abstract DateTime Date { get; set; } [Parameter(222L)] public abstract Decimal Decimal1 { get; set; } [Parameter(-2.05)] public abstract Decimal Decimal2 { get; set; } [NewGuidParameter] public abstract Guid Guid { get; set; } }

[Test] public void Test() { TestObject1 o = (TestObject1)TypeAccessor.CreateInstance(typeof(TestObject1));

Assert.That(o.Str, Is.EqualTo("t")); Assert.That(o.Int, Is.EqualTo(54)); Assert.That(o.Date, Is.EqualTo(new DateTime(2,2,2))); Assert.That(o.Decimal1, Is.EqualTo(222m)); Assert.That(o.Decimal2, Is.EqualTo(-2.05m)); Assert.That(o.Guid, Is.Not.EqualTo(Guid.Empty)); } } }
© 2010 www.bltoolkit.net