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);
            }
            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);
            }
            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);
            }
            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);
            }
            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);
            }
Ejemplo n.º 6
0
 private void MoveRuleToFront(CallRuleMetadata rule)
 {
     if (this.allUserRulesField.Remove(rule))
     {
         this.allUserRulesField.AddFirst(rule);
     }
 }
Ejemplo n.º 7
0
 private static void ApplyRule(CallRuleMetadata rule, IInterceptedFakeObjectCall fakeObjectCall)
 {
     rule.CalledNumberOfTimes++;
     rule.Rule.Apply(fakeObjectCall);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds a call rule last in the list of user rules, meaning it has the lowest priority possible.
 /// </summary>
 /// <param name="rule">The rule to add.</param>
 public virtual void AddRuleLast(IFakeObjectCallRule rule)
 {
     var newRule = new CallRuleMetadata { Rule = rule };
     FakeScope.Current.AddRuleLast(this, newRule);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds a fake object call to the current scope.
 /// </summary>
 /// <param name="fakeManager">The fake object.</param>
 /// <param name="rule">The rule to add.</param>
 internal void AddRuleFirst(FakeManager fakeManager, CallRuleMetadata rule)
 {
     fakeManager.AllUserRules.AddFirst(rule);
     this.OnAddRule(fakeManager, rule);
 }
Ejemplo n.º 10
0
 protected override void OnAddRule(FakeManager fakeObject, CallRuleMetadata rule)
 {
 }
Ejemplo n.º 11
0
            protected override void OnAddRule(FakeManager fakeObject, CallRuleMetadata rule)
            {
                List<CallRuleMetadata> rules;

                if (!this.rulesField.TryGetValue(fakeObject, out rules))
                {
                    rules = new List<CallRuleMetadata>();
                    this.rulesField.Add(fakeObject, rules);
                }

                rules.Add(rule);
            }
Ejemplo n.º 12
0
 protected abstract void OnAddRule(FakeManager fakeObject, CallRuleMetadata rule);
Ejemplo n.º 13
0
 private static void ApplyRule(CallRuleMetadata rule, IInterceptedFakeObjectCall fakeObjectCall)
 {
     Logger.Debug("Applying rule {0}.", rule.Rule.ToString());
     rule.CalledNumberOfTimes++;
     rule.Rule.Apply(fakeObjectCall);
 }
Ejemplo n.º 14
0
        public void AddScopeRuleLast(IFakeObjectCallRule rule)
        {
            Guard.AgainstNull(rule, "rule");

            var newRule = new CallRuleMetadata { Rule = rule };
            postManagerRulesField.AddLast(newRule);
        }
Ejemplo n.º 15
0
 private static void ApplyRule(CallRuleMetadata rule, IInterceptedFakeObjectCall fakeObjectCall)
 {
     rule.CalledNumberOfTimes++;
     rule.Rule.Apply(fakeObjectCall);
 }
Ejemplo n.º 16
0
 private static void ApplyRule(CallRuleMetadata rule, IInterceptedFakeObjectCall fakeObjectCall)
 {
     logger.Debug("Applying rule {0}.", rule.Rule.ToString());
     rule.CalledNumberOfTimes++;
     rule.Rule.Apply(fakeObjectCall);
 }