public void Rec_HappyExpando() { converter = new DataConverter( IdentityConverter.Instance, new TryParseConverter(), new ToStringConverter(true), RecordConverter.ForReadOnlyDictionaries(), RecordConverter.ForDictionaries(), ToObjectConverter.Instance, new DynamicConverter()); var e = new ExpandoObject(); dynamic d = e; d.FirstName = "Joost"; d.LastName = "Morsink"; d.Age = 38; Assert.IsTrue(converter.Convert(e).TryTo(out PersonS p)); Assert.AreEqual("Joost", p.FirstName); Assert.AreEqual("Morsink", p.LastName); Assert.AreEqual(38, p.Age); Assert.IsTrue(converter.Convert(p).TryTo(out e)); d = e; Assert.AreEqual("Joost", d.FirstName); Assert.AreEqual("Morsink", d.LastName); Assert.AreEqual(38, d.Age); }
public void Init() { converter = new DataConverter( IdentityConverter.Instance, new TryParseConverter(), new ToStringConverter(true), RecordConverter.ForReadOnlyDictionaries(), RecordConverter.ForDictionaries(), new DynamicConverter()); }
public void Rec_StaticUnhappy() { Assert.IsFalse(RecordConverter.ForDictionaries().CanConvert(typeof(object), typeof(Dictionary <string, string>))); Assert.IsFalse(RecordConverter.ForDictionaries().CanConvert(typeof(Dictionary <string, string>), typeof(object))); }