public NodeCheck() { ParentId = 0; ThisId = 0; LeftId = 0; RightId = 0; Value = default(T); NextCheck = null; }
/// <summary> /// A pre-order check of the given node, then the left and /// finally right subtrees. /// </summary> /// <param name="Validator">Node in a graph of tests in pre-order.</param> public void HierarchyCheck(NodeCheck Validator) { NodeCheck _Validator = Validator; Func <T, bool> check = (val) => { return(true); }; Func <Node, bool> Do = (node) => { if (_Validator != null) { _Validator.Update(node); _Validator = _Validator.Verify(_Validator) ? _Validator.NextCheck : null; } return(_Validator != null); }; PreOrder(_Root, Do, check); }
public static NodeCheck ConvirmValue(T _Value) { NodeCheck nc = new NodeCheck(); nc.Verify = (nodeCheck) => { nodeCheck.Value.Equals(_Value).IfFalse(() => { throw new Exception( string.Format("Expected {0} - actual {1}", _Value, nodeCheck.Value ) ); }); Console.WriteLine("Passed {0}", nodeCheck); return(true); }; return(nc); }