public void PointInStructure() { var item = new Item { Point = new DataPoint(1, 2) }; var rp = new ReflectionPath("Point.X"); object result; Assert.IsTrue(rp.TryGetValue(item, out result)); Assert.That(rp.GetValue(item), Is.EqualTo(1)); }
public void Null2() { var item = new Item(); var rp = new ReflectionPath("SubItem.X"); object result; Assert.IsTrue(rp.TryGetValue(item, out result)); Assert.That(rp.GetValue(item), Is.Null); }
public void InvalidPath() { var item = new Item { Point = new DataPoint(1, 2) }; var rp = new ReflectionPath("Point.Z"); object result; Assert.IsFalse(rp.TryGetValue(item, out result)); Assert.Throws<InvalidOperationException>(() => rp.GetValue(item)); }
public void SimpleProperty() { var item = new Item { Number = 41 }; var rp = new ReflectionPath("Number"); object result; Assert.IsTrue(rp.TryGetValue(item, out result)); Assert.That(rp.GetValue(item), Is.EqualTo(41)); }
public void InvalidPath() { var item = new Item { Point = new DataPoint(1, 2) }; var rp = new ReflectionPath("Point.Z"); object result; Assert.IsFalse(rp.TryGetValue(item, out result)); Assert.Throws <InvalidOperationException>(() => rp.GetValue(item)); }