コード例 #1
0
            private static IInvocationDescriptor GetInvocationDescriptor(object actual)
            {
                var invocationDescriptor = actual as IInvocationDescriptor;

                if (invocationDescriptor == null)
                {
                    var testDelegate = actual as TestDelegate;

                    if (testDelegate != null)
                    {
                        invocationDescriptor = new VoidInvocationDescriptor(testDelegate);
                    }

#if NET_4_0 || NET_4_5 || PORTABLE
                    else
                    {
                        var asyncTestDelegate = actual as AsyncTestDelegate;
                        if (asyncTestDelegate != null)
                        {
                            invocationDescriptor = new GenericInvocationDescriptor <System.Threading.Tasks.Task>(() => asyncTestDelegate());
                        }
                    }
#endif
                }
                if (invocationDescriptor == null)
                {
                    throw new ArgumentException(
                              String.Format(
                                  "The actual value must be a TestDelegate or AsyncTestDelegate but was {0}",
                                  actual.GetType().Name),
                              "actual");
                }

                return(invocationDescriptor);
            }
コード例 #2
0
        private static IInvocationDescriptor GetInvocationDescriptor(object actual)
        {
            IInvocationDescriptor invocationDescriptor = actual as IInvocationDescriptor;

            if (invocationDescriptor == null)
            {
                TestDelegate testDelegate = actual as TestDelegate;

                if (testDelegate == null)
                {
                    throw new ArgumentException(
                              String.Format("The actual value must be a TestDelegate or ActualValueDelegate but was {0}", actual.GetType().Name),
                              "actual");
                }

                invocationDescriptor = new VoidInvocationDescriptor(testDelegate);
            }

            return(invocationDescriptor);
        }