コード例 #1
0
        /// <summary>
        /// Creates a new Session Command.
        /// </summary>
        /// <param name="safeSession"> The safe session object.</param>
        /// <param name="unitTestSession"> The session that contains the unit tests.</param>
        public SessionCommand(Session safeSession, Session unitTestSession)
            : this()
        {
            this.SafeSession = safeSession;
            this.TestSession = unitTestSession;

            updateElementNames.Add("__VIEWSTATE");
            updateElementNames.Add("__EVENTTARGET");
        }
コード例 #2
0
        /// <summary>
        /// Loads an exising Session type.
        /// </summary>
        /// <param name="session"> Loads a session type in the ScriptingDataDesigner.</param>
        public void LoadSession(Session session)
        {
            ScriptingApplication sd = new ScriptingApplication();

            foreach (SessionRequest req in session.SessionRequests )
            {
                if ( req.RequestType == HttpRequestType.GET )
                {
                    GetWebRequest getRequest = new GetWebRequest((GetSessionRequest)req);
                    sd.AddWebRequest(getRequest);
                }
                else if ( req.RequestType == HttpRequestType.POST )
                {
                    PostWebRequest postRequest = new PostWebRequest((PostSessionRequest)req);
                    sd.AddWebRequest(postRequest);
                }
            }

            _scriptingData = sd;
        }
コード例 #3
0
        /// <summary>
        /// Opens a template for the url spider.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //        private void btnOpenTemplate_Click(object sender, System.EventArgs e)
        //        {
        //            // send this to disk
        //            System.IO.Stream stream = null;
        //
        //            dlgOpenFile.CheckFileExists = true;
        //            dlgOpenFile.InitialDirectory = Application.UserAppDataPath;
        //            dlgOpenFile.RestoreDirectory = true;
        //            dlgOpenFile.Filter = "Web Unit Test Template Files (*.gbtt)|*.gbtt";
        //            dlgOpenFile.Title = "Open Web Unit Test Template";
        //
        //            if ( dlgOpenFile.ShowDialog() == DialogResult.OK )
        //            {
        //                Application.DoEvents();
        //                tempCursor = Cursor.Current;
        //                Cursor.Current = Cursors.WaitCursor;
        //
        //                // file
        //                stream = dlgOpenFile.OpenFile();
        //                if ( stream != null )
        //                {
        //                    try
        //                    {
        //                        // Load template
        //                        UnitTestTemplateManager testManager = new UnitTestTemplateManager();
        //                        _testTemplate = testManager.OpenTemplate(stream);
        //
        //                        // Enabled run tests
        //                        btnRunUrlSpider.Enabled = true;
        //
        //                        FileInfo file = new FileInfo(dlgOpenFile.FileName);
        //                        
        //                        // Set template name.
        //                        ShowMessage("Template '" + file.Name + "' loaded.\r\n");
        //                    }
        //                    catch ( Exception ex )
        //                    {
        //                        MessageBox.Show(ex.Message,AppLocation.ApplicationName,MessageBoxButtons.OK, MessageBoxIcon.Error);
        //                    }
        //                }
        //            }
        //
        //            if (stream != null)
        //            {
        //                Cursor.Current = tempCursor;
        //                stream.Close();
        //            }
        //        }
        /// <summary>
        /// Runs the url spider tests.
        /// </summary>
        private void RunUrlSpider()
        {
            Application.DoEvents();
            tempCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            foreach ( DictionaryEntry de in _testTemplate )
            {
                Test test = (Test)de.Value;
                test.UnitTestDataType = UnitTestDataContainer.NoPostData;
            }

            foreach ( SessionRequest sr in urlSpiderControl.UrlRequests )
            {
                sr.WebUnitTest.Tests = _testTemplate;
            }

            //EnabledUnitTestView(true);

            // Create new session
            Session safeSession =  new Session();
            safeSession.IsCookieUpdatable = false;
            safeSession.SessionDate = DateTime.Now;
            safeSession.AllowSafeRequestBacktracking = false;
            safeSession.SessionRequests = urlSpiderControl.UrlRequests;

            // Run Session Command
            sessionCommand = new SessionCommand(safeSession, safeSession.CloneSession());
            sessionCommand.ProtocolProperties = this.ClientProperties;
            sessionCommand.Proxy = this.ProxySettings;

            // this event is for aborting
            sessionCommand.SessionAbortedEvent += new SessionAbortEventHandler(unitTestCommand_SessionAbortedEvent);
            // this event displays a report
            sessionCommand.CreateReportEvent += new UnitTestSessionReportEventHandler(UrlSpider_CreateReportEvent);
            // this event displays the progress
            sessionCommand.DisplaySessionProcessEvent += new SessionCommandProcessEventHandler(unitTestCommand_DisplaySessionProcessEvent);
            // start progress bar
            StartProgressBarEvent(this,new ProgressBarControlEventArgs("Running Url Spider..."));
            // process unit tests
            sessionCommand.Run();

            Cursor.Current = tempCursor;
        }
コード例 #4
0
        /// <summary>
        /// Raises when a Record Session button is toggle.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RecordSessionChanged(object sender, EventArgs e)
        {
            ChangeStatusBarEventArgs statusBarArgs =new ChangeStatusBarEventArgs();

            if ( !IsRecording )
            {
                statusBarArgs.Index = 2;
                statusBarArgs.Text = "Recording";
                this.ChangeStatusBarPanelEvent(this, statusBarArgs);

                this.CurrentSessionRecording = new Session();
                IsRecording = true;

            }
            else
            {

                statusBarArgs.Index = 2;
                statusBarArgs.Text = "";
                this.ChangeStatusBarPanelEvent(this, statusBarArgs);

                IsRecording = false;

                if ( this.CurrentSessionRecording.SessionRequests.Count > 0 )
                {
                    _scriptingDataDesigner = new ScriptingDataDesigner();
                    _scriptingDataDesigner.PluginMenus = this.mnSessionMenus;
                    // _scriptingDataDesigner.ApplyMenuSettingsEvent += new ApplyMenuSettingsEventHandler(SessionDesigner_ApplyMenuSettingsEvent);
                    // _scriptingDataDesigner.ApplyToolbarSettingsEvent += new ApplyToolbarSettingsEventHandler(sessionDesigner_ApplyToolbarSettingsEvent);

                    // Loads the sesion into the ui.
                    //UpdateReportDialogTestMenu(false);
                    _scriptingDataDesigner.LoadSession(this.CurrentSessionRecording);
                    _scriptingDataDesigner.DisplayTreeView();

                    // Remove any existing document and add new document.
                    this.RemoveAndAddDocument(_scriptingDataDesigner, "Scripting Application Designer", true);
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Creates a new SessionDocument.
 /// </summary>
 /// <param name="safeSession"> The safe session object.</param>
 /// <param name="testSession"> The test session object.</param>
 public SessionDocument(Session safeSession, Session testSession )
 {
     this._safeSession = safeSession;
     this._testSession = testSession;
 }