using AutoMapper; namespace YLErp.Basic { [TestClass] public class AutoMapperTest { [TestMethod] public void TestDictionToObject() { var dic = new Dictionary { {"AA","11" }, {"BB","22" } }; var poco = new Mapper(new MapperConfiguration(cfg => { })).Map(dic); Assert.IsTrue(poco.AA == "11" && poco.BB == "22"); dic = new Dictionary { {"AA","33" }, {"BB","44" } }; new Mapper(new MapperConfiguration(cfg => { })).Map(dic, poco); Assert.IsTrue(poco.AA == "33" && poco.BB == "44"); } } }