• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IInterceptedFakeObjectCall类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Apply

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

                var newRule = new CallRuleMetadata
                                  {
                                      CalledNumberOfTimes = 1,
                                      Rule = new PropertyBehaviorRule(fakeObjectCall.Method, this.fakeManager)
                                                 {
                                                     Indices = fakeObjectCall.Arguments.Take(fakeObjectCall.Arguments.Count - 1).ToArray(),
                                                     Value = fakeObjectCall.Arguments.Last()
                                                 }
                                  };

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


示例17: Apply

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

                var newRule = new CallRuleMetadata
                                  {
                                      Rule = new PropertyBehaviorRule(fakeObjectCall.Method, FakeManager)
                                      {
                                          Value = CreateFake(fakeObjectCall.Method.ReturnType),
                                          Indices = fakeObjectCall.Arguments.ToArray(),
                                      },
                                      CalledNumberOfTimes = 1
                                  };

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


示例18: Apply

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

            foreach (var action in this.Actions)
            {
                action.Invoke(fakeObjectCall);
            }

            this.Applicator.Invoke(fakeObjectCall);
            this.ApplyOutAndRefParametersValueProducer(fakeObjectCall);

            if (this.CallBaseMethod)
            {
                fakeObjectCall.CallBaseMethod();
            }
        }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:17,代码来源:BuildableCallRule.cs


示例19: Apply

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

                var newRule = new CallRuleMetadata
                                  {
                                      Rule = new PropertyBehaviorRule(fakeObjectCall.Method, this.fakeManager)
                                      {
                                          Value = fakeObjectCall.GetDefaultReturnValue(),
                                          Indices = fakeObjectCall.Arguments.ToArray(),
                                      },
                                      CalledNumberOfTimes = 1
                                  };

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


示例20: Apply

            public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
            {
                if (this.TryHandleToString(fakeObjectCall))
                {
                    return;
                }

                if (this.TryHandleGetHashCode(fakeObjectCall))
                {
                    return;
                }

                if (this.TryHandleEquals(fakeObjectCall))
                {
                    return;
                }
            }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:17,代码来源:FakeManager.ObjectMemberRule.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IInterceptor类代码示例发布时间:2022-05-24
下一篇:
C# IInteractiveWindow类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap