/// <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) { lock (this.allUserRules) { this.allUserRules.AddLast(CallRuleMetadata.NeverCalled(rule)); } }
/// <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) { Guard.AgainstNull(rule, nameof(rule)); lock (this.allUserRules) { this.allUserRules.AddLast(CallRuleMetadata.NeverCalled(rule)); } }
/// <summary> /// Adds a call rule to the fake object after the specified rule. /// </summary> /// <param name="previousRule">The rule after which to add a rule.</param> /// <param name="newRule">The rule to add.</param> internal void AddRuleAfter(IFakeObjectCallRule previousRule, IFakeObjectCallRule newRule) { lock (this.allUserRules) { var previousNode = this.allUserRules.Nodes().FirstOrDefault(n => n.Value.Rule == previousRule); if (previousNode is null) { throw new InvalidOperationException(ExceptionMessages.CannotFindPreviousRule); } this.allUserRules.AddAfter(previousNode, CallRuleMetadata.NeverCalled(newRule)); } }
/// <summary> /// Adds a call rule to the fake object after the specified rule. /// </summary> /// <param name="previousRule">The rule after which to add a rule.</param> /// <param name="newRule">The rule to add.</param> internal void AddRuleAfter(IFakeObjectCallRule previousRule, IFakeObjectCallRule newRule) { lock (this.allUserRules) { var previousNode = this.allUserRules.Nodes().FirstOrDefault(n => n.Value.Rule == previousRule); if (previousNode == null) { throw new InvalidOperationException("The rule after which to add the new rule was not found in the list."); } this.allUserRules.AddAfter(previousNode, CallRuleMetadata.NeverCalled(newRule)); } }