view UnitTests/Fluent/FluentMapAttributesTest.cs @ 3:1ef98bd70424

!bug 100 +3h Исправление проблемы BLToolkit + mono 3.4
author cin
date Fri, 22 Aug 2014 17:34:46 +0400
parents f990fcb411a9
children
line wrap: on
line source

using System.Collections.Generic;

using BLToolkit.Data;
using BLToolkit.Mapping.Fluent;
using BLToolkit.Mapping.MemberMappers;
using BLToolkit.Reflection.Extension;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BLToolkit.Fluent.Test
{
	/// <summary>
	/// Test for FluentConfig
	/// </summary>
	[TestClass]
    public class FluentMapAttributesTest
	{
		/// <summary>
		/// Test configure mapping
		/// </summary>
		[TestMethod]
		public void ShouldConfigMapping()
		{
			ExtensionList extensions = new ExtensionList();
            FluentConfig.Configure(extensions).MapingFromAssemblyOf<FluentMapAttributesTest>();

		    var key = extensions[typeof(DboFluentMapAttributesTest).FullName];
		    var mem1 = key["Id"];
            Assert.IsTrue(mem1.Attributes.ContainsKey("Identity"));
		    
            var mem2 = key["Test"];
            Assert.IsTrue(mem2.Attributes.ContainsKey("MemberMapper"));
            Assert.IsTrue(mem2.Attributes.ContainsKey("DbType"));            
		}

        public class DboFluentMapAttributesTest
		{
            public int Id { get; set; }
            public List<string> Test { get; set; }
		}

        public class DboFluentMapAttributesTestMap : FluentMap<DboFluentMapAttributesTest>
		{
            public DboFluentMapAttributesTestMap()
			{
				TableName("t1");

			    MapField(x => x.Id).Identity();
			    MapField(x => x.Test).MapIgnore(false).MemberMapper(typeof(BinarySerialisationMapper)).DbType(System.Data.DbType.Binary);
			}
		}
		
	}
}