private BehaviorChain BehaviorForActionCall(ActionCall call) { BehaviorChain chain = Behaviors.FirstOrDefault(x => x.FirstCall().Equals(call)); if (chain == null) { throw new FubuException(2152, "Could not find a behavior for action {0}", call.Description); } return(chain); }
/// <summary> /// Performs an invocation on the mock. /// </summary> /// <remarks> /// Whether or not a behavior matches the invocation, the actual invocation /// is always recorded. /// </remarks> public virtual void Invoke(IInvocation invocation) { Invocations.Add(invocation); var behavior = Behaviors.FirstOrDefault(x => x.AppliesTo(invocation)); if (behavior != null) { behavior.ExecuteFor(invocation); } }
/// <summary> /// Finds the Id of the BehaviorChain containing /// the ActionCall /// </summary> /// <param name = "call"></param> /// <returns></returns> public Guid IdForCall(ActionCall call) { var chain = Behaviors.FirstOrDefault(x => x.FirstCall().Equals(call)); if (chain == null) { throw new FubuException(2152, "Could not find a behavior for action {0}", call.Description); } return(chain.UniqueId); }
protected virtual void ToggleValidationBehavior() { if (Mandatory && Behaviors.Where(b => b is EntryMandatory).ToArray().Length == 0) { Behaviors.Add(new EntryMandatory()); } else { var behavior = Behaviors.FirstOrDefault(b => b is EntryMandatory); if (behavior != null) { Behaviors.Remove(behavior); } } }
public BehaviorChain FindHomeChain() { return(Behaviors.FirstOrDefault(x => x.Route != null && x.Route.Pattern == string.Empty)); }