view UnitTests/CS/DataAccess/XmlExtension.cs @ 9:1e85f66cf767 default tip

update bltoolkit
author nickolay
date Thu, 05 Apr 2018 20:53:26 +0300
parents f990fcb411a9
children
line wrap: on
line source

using System;

using NUnit.Framework;

using BLToolkit.DataAccess;
using BLToolkit.Mapping;
using BLToolkit.Reflection.Extension;
using BLToolkit.Data;

namespace DataAccess
{
	[TestFixture]
	public class XmlExtension
	{
		public class Person1
		{
			[MapField("PersonID")]  public int    ID;
			[MapField("FirstName")] public string Name;
		}

		[Test]
		public void Test()
		{
			using (DbManager db = new DbManager())
			{
				SqlQuery          sq = new SqlQuery(db);
				sq.Extensions = TypeExtension.GetExtensions(@"XmlExtension.xml");
				Assert.IsNotNull(sq.Extensions["Person1"]);

				Person1           ps = (Person1)sq.SelectByKey(typeof(Person1), 1);
				Assert.IsNotNull(ps);
			}
		}

		[Test]
		public void GenericsTest()
		{
			using (DbManager db = new DbManager())
			{
				SqlQuery<Person1> sq = new SqlQuery<Person1>(db);
				sq.Extensions = TypeExtension.GetExtensions(@"XmlExtension.xml");
				Assert.IsNotNull(sq.Extensions["Person1"]);

				Person1           ps = sq.SelectByKey(1);
				Assert.IsNotNull(ps);
			}
		}
	}
}