/// <summary>
        /// Validate the Workflow.
        /// </summary>
        /// <param name="expectEmptyActions"></param>
        public override void Validate(bool expectEmptyActions)
        {
            if (expectEmptyActions)
            {
                Utils.AssertArgument(this.Actions == null || this.Actions.Count() == 0, "Actions must either be null or empty collection");
            }
            else
            {
                RealTimeMediaValidActions.Validate(this.Actions);
            }

            if (this.Links != null)
            {
                if (this.Links.Notification != null)
                {
                    // Notification link is optional. Notification link - if specified - must be absolute https uri.
                    Utils.AssertArgument(this.Links.Notification.IsAbsoluteUri, "Notification link must be an absolute uri");
                    Utils.AssertArgument(this.Links.Notification.Scheme == "https", "Notification link must be an secure https uri");
                    Utils.AssertArgument(this.NotificationSubscriptions != null, "Notification subscriptions must be specified if notification link is given");
                }

                Utils.AssertArgument(this.Links.Callback != null, "Callback link cannot be specified as null");
                Utils.AssertArgument(this.Links.Callback.IsAbsoluteUri, "Callback link must be an absolute uri");
                Utils.AssertArgument(this.Links.Callback.Scheme == "https", "Callback link must be an secure HTTPS uri");
            }

            ApplicationState.Validate(this.AppState);
        }
        public static void Validate(IEnumerable <ActionBase> actions)
        {
            Utils.AssertArgument(actions != null, "Null Actions List not allowed");
            ActionBase[] actionsToBeValidated = actions.ToArray();
            Utils.AssertArgument(actionsToBeValidated.Length > 0, "Empty Actions List not allowed");

            if (actionsToBeValidated.Length > 1 && actionsToBeValidated.Any((a) => { return(a.IsStandaloneAction); }))
            {
                Utils.AssertArgument(
                    false,
                    "The stand-alone action '{0}' cannot be specified with any other actions",
                    (actionsToBeValidated.FirstOrDefault((a) => { return(a.IsStandaloneAction); })).Action);
            }

            // Validate each action is correct.
            for (int i = 0; i < actionsToBeValidated.Length; ++i)
            {
                Utils.AssertArgument(actionsToBeValidated[i] != null, "action {0} cannot be null", i);
                RealTimeMediaValidActions.Validate(actionsToBeValidated[i].Action);
                actionsToBeValidated[i].Validate();
            }

            // Ensure that actions are not duplicated
            for (int i = 0; i < actionsToBeValidated.Length; ++i)
            {
                int actionCount = actionsToBeValidated.Where(a => a.Action == actionsToBeValidated[i].Action).Count();
                Utils.AssertArgument(actionCount <= 1, "Action {0} can not be specified multiple times in same workflow.", actionsToBeValidated[i].Action);
            }

            // Some actions (AnswerAppHostedMedia) cannot be combined in one workflow.
            var exclusiveActions = actionsToBeValidated.Where(a => RealTimeMediaValidActions.IsExclusiveAction(a.Action)).ToArray();

            if (exclusiveActions.Count() > 1)
            {
                Utils.AssertArgument(false, "Action {0} can not be specified with action {1}.", exclusiveActions[0].Action, exclusiveActions[1].Action);
            }
        }
 public static void Validate(string action)
 {
     Utils.AssertArgument(!String.IsNullOrWhiteSpace(action), "Action Name cannot be null or empty");
     Utils.AssertArgument(RealTimeMediaValidActions.IsValidAction(action), "{0} is not a valid action", action);
 }