private static IExpectationContext GetParentOf(IExpectationContext child) { var propInfo = child.GetType() .GetPublicInstanceProperty(nameof(IExpectationContext.Parent)); return(propInfo?.GetValue(child) as IExpectationContext); }
private static bool TryReadIsNegatedOn(IExpectationContext current) { var propInfo = current .GetType() .GetPublicInstanceProperties() .FirstOrDefault(pi => pi.Name == "isnegated"); return((bool?)propInfo?.GetValue(current) ?? false); }
private static bool IsNegatedPrivate(IExpectationContext current) { var propInfo = current.GetType().GetProperty(nameof(ExpectationBase.IsNegated)); if (propInfo is null) { return(false); } try { return((bool)propInfo.GetValue(current)); } catch { return(false); } }