public void Map_ConcreteType_Success()
        {
            TinyMapper.Bind<Source2, Target2>(config =>
            {
                config.Bind(target => target.Ints, typeof(List<int>));
                config.Bind(target => target.Strings, typeof(List<string>));
            });

            var source = new Source2
            {
                Ints = new List<int> { 1, 2, 3 },
                Strings = new List<string> { "A", "B", "C" }
            };

            var actual = TinyMapper.Map<Target2>(source);
            Assert.Equal(source.Ints, actual.Ints);
            Assert.Equal(source.Strings, actual.Strings);
        }
        public void Map_IgnoreProperties_Success()
        {
            TinyMapper.Bind<Source2, Target2>(config =>
            {
                config.Ignore(x => x.FirstName);
                config.Ignore(x => x.LastName);
            });

            var source = new Source2
            {
                Id = 1,
                FirstName = "First",
                LastName = "LastName"
            };

            var actual = TinyMapper.Map<Target2>(source);

            Assert.Equal(source.Id, actual.Id);
            Assert.Null(actual.FirstName);
            Assert.Null(actual.LastName);
        }
        public void Map_DifferentKeyDictionary_Success()
        {
            TinyMapper.Bind<ItemKeySource, ItemKeyTarget>();
            TinyMapper.Bind<Source2, Target2>();

            var source = new Source2
            {
                Id = Guid.NewGuid(),
                Dictionary = new Dictionary<ItemKeySource, int>
                {
                    { new ItemKeySource { Id = Guid.NewGuid() }, 1 },
                    { new ItemKeySource { Id = Guid.NewGuid() }, 2 },
                }
            };

            var target = TinyMapper.Map<Target2>(source);

            Assert.Equal(source.Id, target.Id);
            Assert.Equal(source.Dictionary.Keys.Select(x => x.Id), target.Dictionary.Keys.Select(x => x.Id));
            Assert.Equal(source.Dictionary.Values, target.Dictionary.Values);
        }
        public void Map_Collections_Success()
        {
            TinyMapper.Bind<Source2, Target2>();
            var source = new Source2
            {
                Bool = new List<bool> { true, false },
                Byte = new List<byte> { 0, 1 },
                Char = new List<char> { 'a', 'b' },
                Decimal = new List<decimal> { 1, 2 },
                Double = new List<double> { 2, 3 },
                Float = new List<float> { 1, 5 },
                Int = new List<int> { 0, 4, 3 },
                Long = new List<long> { 90, 23 },
                Sbyte = new List<sbyte> { 1, 1 },
                Short = new List<short> { 10, 11 },
                String = new List<string> { "f", "q" },
                Uint = new List<uint> { 9, 9 },
                Ulong = new List<ulong> { 2, 1 },
                Ushort = new List<ushort> { 5, 5 }
            };

            var target = TinyMapper.Map<Target2>(source);

            Assert.Equal(target.Bool, source.Bool);
            Assert.Equal(target.Byte, source.Byte);
            Assert.Equal(target.Char, source.Char);
            Assert.Equal(target.Decimal, source.Decimal);
            Assert.Equal(target.Double, source.Double);
            Assert.Equal(target.Float, source.Float);
            Assert.Equal(target.Int, source.Int);
            Assert.Equal(target.Long, source.Long);
            Assert.Equal(target.Sbyte, source.Sbyte);
            Assert.Equal(target.Short, source.Short);
            Assert.Equal(target.String, source.String);
            Assert.Equal(target.Uint, source.Uint);
            Assert.Equal(target.Ulong, source.Ulong);
            Assert.Equal(target.Ushort, source.Ushort);
        }
 public static Source2_ Convert(Source2 source)
 {
     return new Source2_ { Data = source.Data };
 }
        public void Map_NullCollection_Success()
        {
            var source = new Source2
            {
                Int = 1
            };

            var actual = TinyMapper.Map<Target2>(source);

            Assert.Equal(source.Ints, actual.Ints);
            Assert.Equal(source.Int, actual.Int);
        }