Example #1
0
        public void AnExceptionIsThrownIfATypeHasACreateMapMethodButNoAttributeInStrictMode()
        {
            var typesToIgnore = new List <Type>()
            {
                typeof(MappedObjectWithCreateMapMethod),
                typeof(MappedObjectWithCreateMapMethodWhichThrowsException),
                typeof(MappedObjectWithoutCreateMapMethod)
            };

            MappedObjectInitializer.Initialize(typeof(MappedObjectTest).Assembly, typesToIgnore, true);
        }
Example #2
0
        public void AnExceptionIsThrownIfAMappingInitializerThrowsAnException()
        {
            int initialCount = MappedObjectWithCreateMapMethod.CreateMapCount;

            var typesToIgnore = new List <Type>()
            {
                typeof(MappedObjectInitializer),
                typeof(MappedObjectWithCreateMapMethod),
                typeof(ObjectWithCreateMapMethodButNoAttribute)
            };

            MappedObjectInitializer.Initialize(typeof(MappedObjectTest).Assembly, typesToIgnore, true);
        }
Example #3
0
        public void AnExceptionIsNotThrownIfATypeHasACreateMapMethodButNoAttributeInStrictMode()
        {
            var typesToIgnore = new List <Type>()
            {
                typeof(MappedObjectWithCreateMapMethod),
                typeof(MappedObjectWithCreateMapMethodWhichThrowsException),
                typeof(MappedObjectWithoutCreateMapMethod)
            };

            List <Type> success = MappedObjectInitializer.Initialize(typeof(MappedObjectTest).Assembly, typesToIgnore, false);

            Assert.That(success.Count, Is.EqualTo(0));
        }
Example #4
0
        public void TheCreateMapMethodIsCalledOnTypesWithACreateMapMethodAndAttribute()
        {
            int initialCount = MappedObjectWithCreateMapMethod.CreateMapCount;

            var typesToIgnore = new List <Type>()
            {
                typeof(MappedObjectWithCreateMapMethodWhichThrowsException),
                typeof(MappedObjectWithoutCreateMapMethod),
                typeof(ObjectWithCreateMapMethodButNoAttribute)
            };

            List <Type> success = MappedObjectInitializer.Initialize(typeof(MappedObjectTest).Assembly, typesToIgnore, true);

            Assert.That(success.Count, Is.EqualTo(1));
            Assert.That(success.First(), Is.EqualTo(typeof(MappedObjectWithCreateMapMethod)));
            Assert.That(MappedObjectWithCreateMapMethod.CreateMapCount, Is.GreaterThan(initialCount));
        }