public void Traverse2_Static_Field_Instance_Field() { var extra = new Traverse2_ExtraClass("test1"); Assert.AreEqual("test1", Traverse2.Create(extra).Field("someString").GetValue()); Assert.AreEqual("test2", Traverse2Fields_Static.extraClassInstance.someString, "direct"); var trv = Traverse2.Create(typeof(Traverse2Fields_Static)); var trv2 = trv.Field("extraClassInstance"); Assert.AreEqual(typeof(Traverse2_ExtraClass), trv2.GetValue().GetType()); Assert.AreEqual("test2", trv2.Field("someString").GetValue(), "Traverse2"); }
public void Traverse2_Instance_Field_Static_Field() { var instance = new Traverse2_ExtraClass("test3"); Assert.AreEqual(typeof(Traverse2_BaseClass), instance.baseClass.GetType()); var trv1 = Traverse2.Create(instance); Assert.NotNull(trv1, "trv1"); var trv2 = trv1.Field("baseClass"); Assert.NotNull(trv2, "trv2"); var val = trv2.GetValue(); Assert.NotNull(val, "val"); Assert.AreEqual(typeof(Traverse2_BaseClass), val.GetType()); var trv3 = trv2.Field("baseField"); Assert.NotNull(trv3, "trv3"); Assert.AreEqual("base-field", trv3.GetValue()); }