public void Test0_1()
        {
            IServiceCollection sc = new ServiceCollection()
                                    .AddLightweightMapper();

            IServiceProvider sp       = sc.BuildServiceProvider();
            IMapperProvider  provider = sp.GetRequiredService <IMapperProvider>();

            Assert.Equal(10, provider.Convert <int, int>(10));
            Assert.Null(provider.Convert <int?, int?>(null));
            Assert.Equal(10, provider.Convert <int?, int>(10));
            Assert.Null(provider.Convert <int, byte?>(300));
            Assert.Equal(0, provider.Convert <int, byte>(300));

            Assert.Equal("A", provider.Convert <string, string>("A"));
            Assert.Equal(new DateTime(2010, 1, 1), provider.Convert <DateTime, DateTime>(new DateTime(2010, 1, 1)));
            Assert.Equal(new DateTime(), provider.Convert <DateTime?, DateTime>(null));
            Assert.Null(provider.Convert <DateTime?, DateTime?>(null));

            var list = provider.ConvertList <string, string>(new List <string>()
            {
                "A", "B"
            });

            Assert.Equal("B", list[1]);

            var dic = provider.Convert <Dictionary <string, int>, Dictionary <string, byte?> >(new Dictionary <string, int>()
            {
                { "A", 300 },
                { "B", 10 }
            });

            Assert.Null(dic["A"]);
            Assert.Equal(10, dic["B"].Value);
        }
        public void Test9()
        {
            IServiceCollection sc = new ServiceCollection()
                                    .AddLightweightMapper();

            IServiceProvider sp       = sc.BuildServiceProvider();
            IMapperProvider  provider = sp.GetRequiredService <IMapperProvider>();

            S5 s5 = new S5()
            {
                S1 = new S1()
                {
                    A = 10
                }
            };

            s5.Self = s5;

            T5 t5 = provider.Convert <S5, T5>(s5);

            Assert.Equal(t5.Self, t5);
            Assert.Equal(10, t5.T1.A);

            // List
            List <S5> list = new List <S5>();

            list.Add(s5);
            list.Add(s5);
            list.Add(s5);

            List <T5> t5List = provider.ConvertList <S5, T5>(list);

            Assert.NotNull(t5List);
            Assert.Equal(3, t5List.Count);
            Assert.Equal(t5List[0], t5List[1]);
            Assert.Equal(t5List[0], t5List[2]);

            Dictionary <S5, S5> dic = new Dictionary <S5, S5>()
            {
                { s5, s5 },
                { new S5()
                  {
                      S1 = new S1 {
                          A = 11
                      }
                  }, s5 }
            };

            var targetDic = provider.Convert <Dictionary <S5, S5>, Dictionary <T5, T5> >(dic);

            Assert.NotNull(targetDic);
            Assert.Equal(2, targetDic.Count);
            var item1 = dic.First();
            var item2 = dic.Last();

            Assert.Equal(item1.Value, item2.Value);
            Assert.Equal(item1.Key, item1.Value);
            Assert.Equal(11, item2.Key.S1.A);
        }