Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <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);
            }
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
 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);
         }
     }
 }
Beispiel #5
0
 public BehaviorChain FindHomeChain()
 {
     return(Behaviors.FirstOrDefault(x => x.Route != null && x.Route.Pattern == string.Empty));
 }