public void InvokeMarkedFunctionTest() { var root = new Root(); PWalk.InvokeMarkedWith <FuncMarkAttribute>(root, new object[] { PWalkProxyParameter.Mark, }); Assert.IsTrue(root.FuncHolder.Text == Target3.VisitedText); }
public void TargetTypeTest() { var root = new Root(); PWalk.TargetType <Target1>(_ => _.Invoke(), root, 1); Assert.IsTrue(root.WalkPathClass.Target.InvokedCount == 1); Assert.IsTrue(root.WalkPathProperty.Target.InvokedCount == 1); Assert.IsTrue(root.WalkSkipProperty.Target.InvokedCount == 0); }
public void InvokeMarkedEventTest() { var root = new Root(); const string VisitedText = "visited"; var invokeCount = 0; EventHandler <ItemEventArgs <string> > handler = (sender, e) => { ++invokeCount; Assert.IsTrue(e.Item == VisitedText); }; root.FuncHolder.Visited += handler; PWalk.InvokeMarkedWith <EventMarkAttribute>(root, new object[] { PWalkProxyParameter.Current, new ItemEventArgs <string>(VisitedText) }); root.FuncHolder.Visited -= handler; Assert.IsTrue(invokeCount == 1); var builder = new StringBuilder(); }
public void MarkedWithTest() { var root = new Root(); Action <object, PWalkContext> action = (_, context) => { var type = context.CurrentNode.AssignedType; if (type != null) { if (type == typeof(string)) { var stringMark = (StringMarkAttribute)context.CurrentMark; context.CurrentNode.Value = stringMark.Text; } } }; PWalk.MarkedWith <StringMarkAttribute>(action, root); Assert.IsTrue(root.StringHolder.Text == Target2.VisitedText); }
protected virtual void OnSetup() { PWalk.TargetType <IDataProperty>(ProvidePropertyPresentation, Core); }