public void NotSameTypePropertyException_Exception()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            expected.ForMember(s => s.PropInt1, d => d.PropString2);
            expected.CreateMappingExpression(null);
        }
        public void CreateCommonMember_IgnoreProperty()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            expected.Ignore(d => d.PropInt1);
            expected.CreateCommonMemberTest();
        }
        public void Ignore_Add_Succes()
        {
            var actual = new MapperConfigurationTestContainer();

            actual.Ignore((d) => d.PropInt1);
            Assert.Equal(1, actual.GetIgnoreCount());
        }
        public void ReadOnlyPropertyExceptionException_Exception()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            expected.ForMember(s => s.PropInt1, d => d.RealOnlyPropInt1);
            expected.CreateMappingExpression(null);
        }
        public void GetSortedExpression_PropertyNotFound_Exception()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            expected.CreateMappingExpression(null);
            expected.GetSortedExpression("PropNotExist");
        }
        public void Ignore_Add_Succes()
        {
            MapperConfigurationTestContainer actual = null;

            actual = new MapperConfigurationTestContainer();
            actual.Ignore((d) => d.PropInt1);
            Assert.AreEqual(actual.GetIgnoreCount(), 1);
        }
        public void GetPropertyInfo_PropertyNotImplementedExceptionDefault()
        {
            PropertyInfo actual = null;
            MapperConfigurationTestContainer       expected = new MapperConfigurationTestContainer();
            Expression <Func <ClassDest, object> > exp      = x => null;

            actual = expected.GetPropertyInfoTest(exp);
        }
        public void Ignore_Add_Succes()
        {
            MapperConfigurationTestContainer actual = null;

            actual = new MapperConfigurationTestContainer();
            actual.Ignore((d) => d.PropInt1);
            Assert.AreEqual(actual.GetIgnoreCount(), 1);
        }
 public void GetMapper_NoFoundMapperException()
 {
     Assert.Throws <NoFoundMapperException>(() =>
     {
         MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
         expected.GetMapperTest(typeof(string), typeof(string), true);
     });
 }
        public void GetPropertyInfo_PropertyFound_Success()
        {
            MapperConfigurationTestContainer         expected = new MapperConfigurationTestContainer();
            Expression <Func <ClassSource, object> > exp      = x => x.PropInt1;
            var actual = expected.GetPropertyInfoTest(exp);

            Assert.Equal(actual.Name, "PropInt1");
        }
        public void GetSortedExpression_PropertyFound_Succes()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            expected.CreateMappingExpression(null);
            var actual = expected.GetSortedExpression("PropInt1");

            Assert.Null(actual);
        }
        public void ReverseMap_Success()
        {
            ExpressionMapper.Reset();
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            var actual = expected.ReverseMap();

            Assert.IsType <MapperConfiguration <ClassDest, ClassSource> >(actual);
        }
        public void ReverseMap_Success()
        {
            MapperConfigurationTestContainer             expected = new MapperConfigurationTestContainer();
            MapperConfiguration <ClassDest, ClassSource> actual   = null;

            actual = expected.ReverseMap();

            Assert.IsInstanceOfType(actual, typeof(MapperConfiguration <ClassDest, ClassSource>));
        }
        public void CreateMappingExpression_NotInitialise()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            expected.CreateMappingExpression(null);
            int actual = expected.MemberToMapForNew.Count;

            Assert.IsTrue(actual > 0);
        }
        public void ReverseMap_MapperAlreadyExist_Exception()
        {
            MapperConfigurationTestContainer             expected = new MapperConfigurationTestContainer();
            MapperConfiguration <ClassDest, ClassSource> actual   = null;

            expected.ReverseMap();

            actual = expected.ReverseMap();
            MapperConfigurationCollectionContainer.Instance.RemoveAt(1);
        }
        public void ReverseMap_Success()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            MapperConfiguration<ClassDest, ClassSource> actual = null;

            actual = expected.ReverseMap();

            Assert.IsInstanceOfType(actual, typeof(MapperConfiguration<ClassDest, ClassSource>));

        }
        public void AfterMap_Add_Succes()
        {
            var actual = new MapperConfigurationTestContainer();

            actual.AfterMap((s, d) =>
            {
                //Nothing To Do
            });
            Assert.Equal(1, actual.GetAfterMapActionCount());
        }
 public void GetPropertyInfo_PropertyNotImplementedException()
 {
     Assert.Throws <NotImplementedException>(() =>
     {
         PropertyInfo actual = null;
         MapperConfigurationTestContainer expected  = new MapperConfigurationTestContainer();
         Expression <Func <ClassDest, object> > exp = x => x.PropInt1 > 0;
         actual = expected.GetPropertyInfoTest(exp);
     });
 }
        public void ReverseMap_MapperAlreadyExist_Exception()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            MapperConfiguration<ClassDest, ClassSource> actual = null;
            //For init the first reverse mapping
            expected.ReverseMap();

            actual = expected.ReverseMap();
            //For remove the reverse mapping (for the others tests)
            MapperConfigurationCollectionContainer.Instance.RemoveAt(1);
        }
        public void AfterMap_Add_Succes()
        {
            MapperConfigurationTestContainer actual = null;

            actual = new MapperConfigurationTestContainer();
            actual.AfterMap((s, d) =>
            {
                //Nothing To Do
            });
            Assert.AreEqual(actual.GetAfterMapActionCount(), 1);
        }
        public void CheckAndRemoveMemberDest_PropertyExist_Remove()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            expected.CreateMappingExpression(null);

            int countOri = expected.MemberToMapForNew.Count;

            expected.CheckAndRemoveMemberDestTest("PropInt1");
            Assert.NotEqual(countOri, expected.MemberToMapForNew.Count);
        }
        public void CreateMemberAssignementForExisting_Succes()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            MapperConfigurationCollectionContainer.Instance.Add(expected);

            Mapper.CreateMap <ClassSource2, ClassDest2>();
            expected.CreateMappingExpression(null);

            Assert.IsNotNull(expected.GetDelegateForExistingTargetTest());
        }
        public void CreateCommonMember_FindMapper_NotList_Success()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            Mapper.Reset();
            Mapper.CreateMap <ClassSource2, ClassDest2>();

            expected.CreateMappingExpression(null);
            var actual = expected.GetGenericLambdaExpression();

            Mapper.Reset();
        }
        public void ExecuteAfterActions_Succes()
        {
            bool excecutedAction = false;
            var  actual          = new MapperConfigurationTestContainer();

            actual.AfterMap((s, d) =>
            {
                excecutedAction = true;
            });
            actual.ExecuteAfterActions(new ClassSource(), new ClassDest());
            Assert.True(excecutedAction);
        }
        public void ReverseMap_MapperAlreadyExist_Exception()
        {
            MapperConfigurationTestContainer             expected = new MapperConfigurationTestContainer();
            MapperConfiguration <ClassDest, ClassSource> actual   = null;

            //For init the first reverse mapping
            expected.ReverseMap();

            actual = expected.ReverseMap();
            //For remove the reverse mapping (for the others tests)
            MapperConfigurationCollectionContainer.Instance.RemoveAt(1);
        }
        public void ExecuteAfterActions_Succes()
        {
            MapperConfigurationTestContainer actual = null;
            bool excecutedAction = false;
            actual = new MapperConfigurationTestContainer();
            actual.AfterMap((s, d) =>
            {
                excecutedAction = true;

            });
            actual.ExecuteAfterActions(new ClassSource(), new ClassDest());
            Assert.IsTrue(excecutedAction);
        }
        public void CheckAndConfigureMappingTest_List_SameType_Success()
        {
            ExpressionMapper.Reset();
            ExpressionMapper.CreateMap <ClassSource2, ClassDest2>();

            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();

            MapperConfigurationCollectionContainer.Instance.Add(expected);
            ExpressionMapper.Initialize();
            Expression <Func <ClassSource, object> >     source = s => s.ListString;
            Expression <Func <ClassDest, object> >       target = d => d.ListString;
            Tuple <Expression, Expression, bool, string> tuple  = Tuple.Create(source.Body, target.Body, false, string.Empty);

            expected.CheckAndConfigureMappingTest(tuple);
            Assert.IsNotNull(expected.GetDelegate());
        }
        public void CheckAndConfigureMappingTest_List_NotSameType_Success()
        {
            Mapper.Reset();
            Mapper.CreateMap<ClassSource2, ClassDest2>();
           
            
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            MapperConfigurationCollectionContainer.Instance.Add(expected);
            Mapper.Initialize();
            Expression<Func<ClassSource, object>> source = s => s.ListProp;
            Expression<Func<ClassDest, object>> target = d => d.ListProp;
            Tuple<Expression, Expression, bool, string> tuple = Tuple.Create(source.Body, target.Body, true,string.Empty);
            expected.CheckAndConfigureMappingTest(tuple);
            Assert.IsNotNull(expected.GetDelegate());


        }
        public void CreateMemberAssignementForExisting_Succes()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            MapperConfigurationCollectionContainer.Instance.Add(expected);

            Mapper.CreateMap<ClassSource2, ClassDest2>();
            expected.CreateMappingExpression(null);

            Assert.IsNotNull(expected.GetDelegateForExistingTargetTest());
        }
 public void GetMapper_NoFoundMapperException()
 {
     MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
     expected.GetMapperTest(typeof(string), typeof(string), true);
 }
        public void GetSortedExpression_PropertyNotFound_Exception()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            expected.CreateMappingExpression(null);
            expected.GetSortedExpression("PropNotExist");

        }
        public void GetPropertyInfo_PropertyFound_Success()
        {
            PropertyInfo actual = null;
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            Expression<Func<ClassSource, object>> exp = x => x.PropInt1;
            actual = expected.GetPropertyInfoTest(exp);

            Assert.AreEqual(actual.Name, "PropInt1");

        }
        public void CreateMappingExpression_NotInitialise()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            expected.CreateMappingExpression(null);
            int actual = expected.MemberToMapForNew.Count;
            Assert.IsTrue(actual > 0);

        }
        public void CreateCommonMember_FindMapper_NotList_Success()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            Mapper.Reset();
            Mapper.CreateMap<ClassSource2, ClassDest2>();

            expected.CreateMappingExpression(null);
            var actual = expected.GetGenericLambdaExpression();
            Mapper.Reset();

        }
        public void GetPropertyInfo_PropertyNotImplementedExceptionDefault()
        {
            PropertyInfo actual = null;
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            Expression<Func<ClassDest, object>> exp = x => null;

            actual = expected.GetPropertyInfoTest(exp);

        }
        public void CreateCommonMember_IgnoreProperty()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            expected.Ignore(d => d.PropInt1);
            expected.CreateCommonMemberTest();

        }
        public void CheckAndRemoveMemberDest_PropertyExist_Remove()
        {
            MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
            expected.CreateMappingExpression(null);

            int countOri = expected.MemberToMapForNew.Count;

            expected.CheckAndRemoveMemberDestTest("PropInt1");

            Assert.AreNotEqual(countOri, expected.MemberToMapForNew.Count);
        }
 public void NotSameTypePropertyException_Exception()
 {
     MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
     expected.ForMember(s => s.PropInt1, d => d.PropString2);
     expected.CreateMappingExpression(null);
 }
 public void ReadOnlyPropertyExceptionException_Exception()
 {
     MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
     expected.ForMember(s => s.PropInt1, d => d.RealOnlyPropInt1);
     expected.CreateMappingExpression(null);
 }
 public void GetSortedExpression_PropertyFound_Succes()
 {
     MapperConfigurationTestContainer expected = new MapperConfigurationTestContainer();
     expected.CreateMappingExpression(null);
     LambdaExpression actual = null;
     actual = expected.GetSortedExpression("PropInt1");
     Assert.IsNotNull(actual);
 }