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


C# IInterceptedFakeObjectCall类代码示例

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


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

示例1: 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

示例2: Apply

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

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

        void IFakeObjectCallRule.Apply(IInterceptedFakeObjectCall invocation)
        {
            this.ApplyWasCalled = true;

            if (this.Apply != null)
            {
                this.Apply(invocation);
            }
        }
开发者ID:patrik-hagne,项目名称:FakeItEasy,代码行数:9,代码来源:FakeCallRule.cs

示例5: ResolveReturnValue

        public static object ResolveReturnValue(IInterceptedFakeObjectCall fakeObjectCall)
        {
            object result;
            if (!FakeManager.TryCreateDummy(fakeObjectCall.Method.ReturnType, out result))
            {
                return fakeObjectCall.Method.ReturnType.GetDefaultValue();
            }

            return result;
        }
开发者ID:bman61,项目名称:FakeItEasy,代码行数:10,代码来源:DefaultReturnValueRule.cs

示例6: Apply

            public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
            {
                var newRule = new CallRuleMetadata
                                  {
                                      CalledNumberOfTimes = 1,
                                      Rule = new PropertyBehaviorRule(fakeObjectCall.Method, this.FakeManager) { Value = fakeObjectCall.Arguments[0] }
                                  };

                this.FakeManager.allUserRulesField.AddFirst(newRule);
            }
开发者ID:rajeshpillai,项目名称:FakeItEasy,代码行数:10,代码来源:FakeManager.PropertySetterRule.cs

示例7: Apply

            public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
            {
                var newRule = new CallRuleMetadata
                                  {
                                      Rule = new PropertyBehaviorRule(fakeObjectCall.Method, FakeManager) { Value = CreateFake(fakeObjectCall.Method.ReturnType) },
                                      CalledNumberOfTimes = 1
                                  };

                this.FakeManager.allUserRulesField.AddFirst(newRule);
                newRule.Rule.Apply(fakeObjectCall);
            }
开发者ID:bverburg,项目名称:FakeItEasy,代码行数:11,代码来源:FakeManager.AutoFakePropertyRule.cs

示例8: 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

示例9: 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

示例10: 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

示例11: ResolveReturnValue

        private static object ResolveReturnValue(IInterceptedFakeObjectCall fakeObjectCall)
        {
            object result = null;

            if (!FakeManager.TryCreateDummy(fakeObjectCall.Method.ReturnType, out result))
            {
                result = Helpers.GetDefaultValueOfType(fakeObjectCall.Method.ReturnType);
            }

            return result;
        }
开发者ID:patrik-hagne,项目名称:FakeItEasy,代码行数:11,代码来源:DefaultReturnValueRule.cs

示例12: 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

示例13: 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)
 {
     if (this.recorder.IsRecording)
     {
         this.wrappedRule.Apply(fakeObjectCall);
         this.recorder.RecordCall(fakeObjectCall.AsReadOnly());
     }
     else
     {
         this.recorder.ApplyNext(fakeObjectCall);
     }
 }
开发者ID:jszumigaj,项目名称:FakeItEasy,代码行数:17,代码来源:SelfInitializationRule.cs

示例14: 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

示例15: 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


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