fluent-nhibernate /src/FluentNHibernate.Testing/AutoMapping/BaseAutoMapTester.cs

Language C# Lines 42
MD5 Hash f99425ea3f45dbae19bdf447be8a59f5
Repository https://github.com/dotnetchris/fluent-nhibernate.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using FluentNHibernate.Automapping;
using FluentNHibernate.Utils;
using Iesi.Collections.Generic;
using NUnit.Framework;

namespace FluentNHibernate.Testing.Automapping
{
    public abstract class BaseAutoMapTester<T>
        where T : IAutoMapper, new()
    {
        private T mapper;

        [SetUp]
        public void CreateMapper()
        {
            mapper = new T();
        }

        protected void ShouldMap(Expression<Func<PropertyTarget, object>> property)
        {
            mapper.MapsProperty(ReflectionHelper.GetProperty(property).ToMember()).ShouldBeTrue();
        }

        protected void ShouldntMap(Expression<Func<PropertyTarget, object>> property)
        {
            mapper.MapsProperty(ReflectionHelper.GetProperty(property).ToMember()).ShouldBeFalse();
        }

        protected class PropertyTarget
        {
            public ISet<PropertyTarget> Set { get; set; }
            public IList<PropertyTarget> List { get; set; }
            public int Int { get; set; }
            public string String { get; set; }
            public DateTime DateTime { get; set; }
            public PropertyTarget Entity { get; set; }
        }
    }
}
Back to Top