コード例 #1
0
        public void When_validating_a_any_invariant_methods_Should_return_results(object source, IMethodAccessor methodAccessor, string because, IEnumerable <ValidationResult> expected)
        {
            // Arrange, Act
            var actual = sut.Validate(source, methodAccessor);

            // Assert
            actual.Should().BeEquivalentTo(expected, because);
        }
コード例 #2
0
 private IEnumerable <ValidationResult> ValidateInvariants(object source)
 {
     foreach (var method in methodProvider.GetMethods(source))
     {
         foreach (var result in methodValidator.Validate(source, method))
         {
             yield return(result);
         }
     }
 }
コード例 #3
0
        private void RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
        {
            Guard.ArgumentNotAsyncVoid(method.MethodInfo, nameof(method));
            _methodValidator?.Validate(method.MethodInfo);

            if (AsyncToSyncAdapter.IsAsyncOperation(method.MethodInfo))
            {
                AsyncToSyncAdapter.Await(() => InvokeMethod(method, context));
            }
            else
            {
                InvokeMethod(method, context);
            }
        }
        /// <summary>
        /// invoke the method converting the <paramref name="args"/> if necessary to the appropriate type
        /// </summary>
        /// <param name="args">the arguments for the method</param>
        /// <returns>the return value of the method</returns>
        public object InvokeMethod(params object[] args)
        {
            ArgumentConvertingMethodInvoker invoker = new ArgumentConvertingMethodInvoker();

            invoker.TargetObject = _obj;
            invoker.TargetMethod = _methodName;
            invoker.Arguments    = args;
            invoker.Prepare();
            //invoker.getPreparedMethod().setAccessible(true);
            if (_methodValidator != null)
            {
                _methodValidator.Validate(invoker.GetPreparedMethod());
            }
            return(invoker.Invoke());
        }