public void ShouldGetNullableValue() { Nullable nullable = new Nullable { Value = 123 }; PropertyInfo info = typeof(Nullable).GetProperty("Value"); ReflectorProperty <Nullable, long?> property = new ReflectorProperty <Nullable, long?>(info); Assert.That(property.GetValue(nullable), Is.EqualTo(123)); }
public void ShouldGetValue() { Regular regular = new Regular { Value = "abc" }; PropertyInfo info = typeof(Regular).GetProperty("Value"); ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info); Assert.That(property.GetValue(regular), Is.EqualTo("abc")); }
public void ShouldHandleCastedGetConversion() { Regular item = new Regular { Value = "aBc" }; PropertyInfo info = typeof(Regular).GetProperty("Value"); ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info); ReflectorProperty <Regular, string> casted = property.Cast(x => x.ToLower(), x => x.ToUpper()); Assert.That(casted.GetValue(item), Is.EqualTo("abc")); }