Exemplo n.º 1
0
        public void GetMapperResultThrowsIfObjectNotRegistered()
        {
            var mapper = new DefaultMapper();

            mapper.RegistrationService.Register <Options>();

            Assert.Throws <ArgumentException>(() =>
            {
                mapper.GetMapperResult <OtherOptions>();
            });
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Maps the passed arguments to the specified type
        /// </summary>
        /// <param name="arguments">
        ///    The arguments mapped to the specified type
        /// </param>
        /// <typeparam name="T">
        ///    The type to whom the arguments are mapped
        /// </typeparam>
        /// <returns>
        ///    An instance of the specified type with all
        ///     properties mapped to the passed arguments
        /// </returns>
        private static IMapperResult <T> MapArgumentsToType <T>(string arguments) where T : class, new()
        {
            var mapper = new DefaultMapper();

            mapper.RegistrationService.Register <T>();

            mapper.Map(arguments.SimpleSplitArguments());

            var result = mapper.GetMapperResult <T>();

            return(result);
        }