private static NavigateToUrlCommand CreateCommand()
        {
            var launcher = Substitute.For <IStartProcess>();
            var command  = new NavigateToUrlCommand(launcher);

            return(command);
        }
        public void ExecuteCommand()
        {
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            try
            {
                if (Command != null)
                {
                    Me = (NavigateToUrlCommand)Command;
                }

                if (String.IsNullOrEmpty(Me.NavigateUrl))
                {
                    throw new ApplicationException("NavigateUrl is invalid");
                }
                string url = Common.CreateUrlWithQueryStringContext(Me.NavigateUrl, Me.Context);
                url = String.Format(url, Page.Request.QueryString[Me.EntityID]);

                log.DebugFormat("RedirectUrl:{0}", url);
                Page.Response.Redirect(url, false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                Page.DisplayErrorAlert(ex);

                log.Error(ex);
            }
        }
Exemplo n.º 3
0
 public NavigateToUrlCommandUC(ICommand command, Test test, EditTest parentForm, EditCommand mainCommandForm, IProjectManager projectManager)
 {
     InitializeComponent();
     this.command         = command as NavigateToUrlCommand;
     this.test            = test;
     this.parentForm      = parentForm;
     this.mainCommandForm = mainCommandForm;
     this.projectManager  = projectManager;
 }
        public void Construct_WithNoStartProcess_ShouldSetLauncher()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var command = new NavigateToUrlCommand();

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ProcessLauncher>(command.Launcher);
        }
        public override object ReadJson(JsonReader reader,
                                        Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jo = JObject.Load(reader);

            string type = (string)jo["_type"];

            if (type == typeof(Project).Name)
            {
                Project item = new Project();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(Test).Name)
            {
                Test item = new Test();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(NavigateToUrlCommand).Name)
            {
                Command item = new NavigateToUrlCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(TakeScreenshotCommand).Name)
            {
                Command item = new TakeScreenshotCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(IfContainsStringCommand).Name)
            {
                Command item = new IfContainsStringCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(FillTextboxCommand).Name)
            {
                Command item = new FillTextboxCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            else if (type == typeof(ClickButtonCommand).Name)
            {
                Command item = new ClickButtonCommand();
                serializer.Populate(jo.CreateReader(), item);
                return(item);
            }
            return(null);
        }
Exemplo n.º 6
0
 private void Save()
 {
     if (parentForm != null)
     {
         if (command == null || command.OrderIndex == 0)
         {
             command       = new NavigateToUrlCommand();
             command.Title = mainCommandForm.GetTitle();
             command.Url   = txtUrl.Text;
             Guid?belongToIndex = comboBox1.SelectedValue as Guid?;
             if (belongToIndex.HasValue)
             {
                 command.BelongsToCommandIndex = belongToIndex;
             }
             else
             {
                 command.BelongsToCommandIndex = null;
             }
             command.OrderIndex = 1;
             if (test.Commands.Any())
             {
                 command.OrderIndex = test.Commands.Max(i => i.OrderIndex) + 1;
             }
             test.Commands.Add(command);
         }
         else
         {
             command.Title = mainCommandForm.GetTitle();
             command.Url   = txtUrl.Text;
             Guid?belongToIndex = comboBox1.SelectedValue as Guid?;
             if (belongToIndex.HasValue)
             {
                 command.BelongsToCommandIndex = belongToIndex;
             }
             else
             {
                 command.BelongsToCommandIndex = null;
             }
         }
     }
     projectManager.SaveProject();
 }
        private static NavigateToUrlCommand CreateCommand(IStartProcess launcher)
        {
            var command = new NavigateToUrlCommand(launcher);

            return(command);
        }