Example #1
0
        private static IExpectationContext GetParentOf(IExpectationContext child)
        {
            var propInfo = child.GetType()
                           .GetPublicInstanceProperty(nameof(IExpectationContext.Parent));

            return(propInfo?.GetValue(child) as IExpectationContext);
        }
Example #2
0
        private static bool TryReadIsNegatedOn(IExpectationContext current)
        {
            var propInfo = current
                           .GetType()
                           .GetPublicInstanceProperties()
                           .FirstOrDefault(pi => pi.Name == "isnegated");

            return((bool?)propInfo?.GetValue(current) ?? false);
        }
Example #3
0
        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);
            }
        }