当前位置: 首页>>代码示例>>C#>>正文


C# IInterceptedFakeObjectCall.SetReturnValue方法代码示例

本文整理汇总了C#中IInterceptedFakeObjectCall.SetReturnValue方法的典型用法代码示例。如果您正苦于以下问题:C# IInterceptedFakeObjectCall.SetReturnValue方法的具体用法?C# IInterceptedFakeObjectCall.SetReturnValue怎么用?C# IInterceptedFakeObjectCall.SetReturnValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IInterceptedFakeObjectCall的用法示例。


在下文中一共展示了IInterceptedFakeObjectCall.SetReturnValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Apply

        public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");

            var returnValue = ResolveReturnValue(fakeObjectCall);
            fakeObjectCall.SetReturnValue(returnValue);
        }
开发者ID:patrik-hagne,项目名称:FakeItEasy,代码行数:7,代码来源:DefaultReturnValueRule.cs

示例2: Apply

            public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
            {
                Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));

                var returnType = fakeObjectCall.Method.ReturnType;
                if (typeof(Task).GetTypeInfo().IsAssignableFrom(returnType))
                {
                    Task task;
                    if (returnType == typeof(Task))
                    {
                        task = TaskHelper.Canceled();
                    }
                    else
                    {
                        var taskResultType = returnType.GetTypeInfo().GetGenericArguments()[0];
                        task = TaskHelper.Canceled(taskResultType);
                    }

                    fakeObjectCall.SetReturnValue(task);
                }
                else
                {
                    var token = GetCanceledTokens(fakeObjectCall).First();
                    token.ThrowIfCancellationRequested();
                }
            }
开发者ID:adamralph,项目名称:FakeItEasy,代码行数:26,代码来源:FakeManager.CancellationRule.cs

示例3: Apply

        /// <summary>
        /// Applies an action to the call, might set a return value or throw
        /// an exception.
        /// </summary>
        /// <param name="fakeObjectCall">The call to apply the interceptor to.</param>
        public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");

            var parameters = fakeObjectCall.Arguments.GetUnderlyingArgumentsArray();
            var valueFromWrappedInstance = fakeObjectCall.Method.Invoke(this.wrappedObject, parameters);
            fakeObjectCall.SetReturnValue(valueFromWrappedInstance);
        }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:13,代码来源:WrappedObjectRule.cs

示例4: TryHandleToString

            private bool TryHandleToString(IInterceptedFakeObjectCall fakeObjectCall)
            {
                if (!fakeObjectCall.Method.MethodHandle.Equals(ObjectMethodsMethodHandles[1]))
                {
                    return false;
                }

                fakeObjectCall.SetReturnValue("Faked {0}".FormatInvariant(this.FakeManager.FakeObjectType.FullName));

                return true;
            }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:11,代码来源:FakeManager.ObjectMemberRule.cs

示例5: TryHandleGetHashCode

            private bool TryHandleGetHashCode(IInterceptedFakeObjectCall fakeObjectCall)
            {
                if (!fakeObjectCall.Method.MethodHandle.Equals(ObjectMethodsMethodHandles[2]))
                {
                    return false;
                }

                fakeObjectCall.SetReturnValue(this.FakeManager.GetHashCode());

                return true;
            }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:11,代码来源:FakeManager.ObjectMemberRule.cs

示例6: TryHandleGetHashCode

            private bool TryHandleGetHashCode(IInterceptedFakeObjectCall fakeObjectCall)
            {
                if (!IsSameMethod(fakeObjectCall.Method, ObjectMethods[2]))
                {
                    return false;
                }

                fakeObjectCall.SetReturnValue(this.fakeManager.GetHashCode());

                return true;
            }
开发者ID:bman61,项目名称:FakeItEasy,代码行数:11,代码来源:FakeManager.ObjectMemberRule.cs

示例7: ApplyNext

        /// <summary>
        /// Applies the call if the call has been recorded.
        /// </summary>
        /// <param name="fakeObjectCall">The call to apply to from recording.</param>
        public void ApplyNext(IInterceptedFakeObjectCall fakeObjectCall)
        {
            this.AssertThatCallQueueIsNotEmpty();

            var callToApply = this.callQueue.Dequeue();

            AssertThatMethodsMatches(fakeObjectCall, callToApply);
            ApplyOutputArguments(fakeObjectCall, callToApply);

            fakeObjectCall.SetReturnValue(callToApply.RecordedCall.ReturnValue);
            callToApply.HasBeenApplied = true;
        }
开发者ID:bverburg,项目名称:FakeItEasy,代码行数:16,代码来源:RecordingManager.cs

示例8: Apply

            public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
            {
                if (this.IsPropertyGetter(fakeObjectCall))
                {
                    fakeObjectCall.SetReturnValue(this.Value);
                }
                else
                {
                    this.Value = fakeObjectCall.Arguments[0];
                }

                this.fakeManager.MoveRuleToFront(this);
            }
开发者ID:rajeshpillai,项目名称:FakeItEasy,代码行数:13,代码来源:FakeManager.PropertyBehaviorRule.cs

示例9: Apply

            public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
            {
                Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");

                if (this.IsPropertyGetter(fakeObjectCall))
                {
                    fakeObjectCall.SetReturnValue(this.Value);
                }
                else
                {
                    this.Value = fakeObjectCall.Arguments.Last();
                }

                this.fakeManager.MoveRuleToFront(this);
            }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:15,代码来源:FakeManager.PropertyBehaviorRule.cs

示例10: Apply

        /// <summary>
        /// Applies an action to the call, might set a return value or throw
        /// an exception.
        /// </summary>
        /// <param name="fakeObjectCall">The call to apply the interceptor to.</param>
        public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));

            var parameters = fakeObjectCall.Arguments.GetUnderlyingArgumentsArray();
            object valueFromWrappedInstance;
            try
            {
                valueFromWrappedInstance = fakeObjectCall.Method.Invoke(this.wrappedObject, parameters);
            }
            catch (TargetInvocationException ex)
            {
                ex.InnerException?.Rethrow();
                throw;
            }

            fakeObjectCall.SetReturnValue(valueFromWrappedInstance);
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:23,代码来源:WrappedObjectRule.cs

示例11: TryHandleEquals

            private bool TryHandleEquals(IInterceptedFakeObjectCall fakeObjectCall)
            {
                if (!fakeObjectCall.Method.MethodHandle.Equals(ObjectMethodsMethodHandles[0]))
                {
                    return false;
                }

                var argument = fakeObjectCall.Arguments[0] as ITaggable;

                if (argument != null)
                {
                    fakeObjectCall.SetReturnValue(argument.Tag.Equals(this.FakeManager));
                }
                else
                {
                    fakeObjectCall.SetReturnValue(false);
                }

                return true;
            }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:20,代码来源:FakeManager.ObjectMemberRule.cs

示例12: Apply

        public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));

            fakeObjectCall.SetReturnValue(fakeObjectCall.GetDefaultReturnValue());
        }
开发者ID:adamralph,项目名称:FakeItEasy,代码行数:6,代码来源:DefaultReturnValueRule.cs

示例13: Apply

        public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            var returnValue = ResolveReturnValue(fakeObjectCall);

            fakeObjectCall.SetReturnValue(returnValue);
        }
开发者ID:rajeshpillai,项目名称:FakeItEasy,代码行数:6,代码来源:DefaultReturnValueRule.cs


注:本文中的IInterceptedFakeObjectCall.SetReturnValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。