コード例 #1
0
        /// <summary>
        /// Adds the elements of a <see cref="SessionRequest"/> array 
        /// to the end of the <see cref="SessionRequestList"/>.
        /// </summary>
        /// <param name="array">An <see cref="Array"/> of <see cref="SessionRequest"/> elements
        /// that should be added to the end of the <see cref="SessionRequestList"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="array"/> is a null reference.</exception>    
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="SessionRequestList"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>SessionRequestList</b> has a fixed size.</para></exception>    
        /// <remarks>Please refer to <see cref="ArrayList.AddRange"/> for details.</remarks>
        public virtual void AddRange(SessionRequest[] array)
        {
            if (array == null)
                throw new ArgumentNullException("array");

            if (array.Length == 0) return;
            if (this._count + array.Length > this._array.Length)
                EnsureCapacity(this._count + array.Length);

            ++this._version;
            Array.Copy(array, 0, this._array, this._count, array.Length);
            this._count += array.Length;
        }
コード例 #2
0
 /// <summary>
 /// Searches the entire sorted <see cref="SessionRequestList"/> for an 
 /// <see cref="SessionRequest"/> element using the default comparer 
 /// and returns the zero-based index of the element.
 /// </summary>
 /// <param name="value">The <see cref="SessionRequest"/> object
 /// to locate in the <see cref="SessionRequestList"/>.
 /// This argument can be a null reference.
 /// </param>    
 /// <returns>The zero-based index of <paramref name="value"/> in the sorted 
 /// <see cref="SessionRequestList"/>, if <paramref name="value"/> is found; 
 /// otherwise, a negative number, which is the bitwise complement of the index 
 /// of the next element that is larger than <paramref name="value"/> or, if there 
 /// is no larger element, the bitwise complement of <see cref="Count"/>.</returns>
 /// <exception cref="InvalidOperationException">
 /// Neither <paramref name="value"/> nor the elements of the <see cref="SessionRequestList"/> 
 /// implement the <see cref="IComparable"/> interface.</exception>
 /// <remarks>Please refer to <see cref="ArrayList.BinarySearch"/> for details.</remarks>
 public virtual int BinarySearch(SessionRequest value)
 {
     return Array.BinarySearch(this._array, 0, this._count, value);
 }
コード例 #3
0
 public override void AddRange(SessionRequest[] array)
 {
     throw new NotSupportedException("Read-only collections cannot be modified.");
 }
コード例 #4
0
        /// <summary>
        /// Adds a <see cref="SessionRequest"/> to the end of the <see cref="SessionRequestList"/>.
        /// </summary>
        /// <param name="value">The <see cref="SessionRequest"/> object 
        /// to be added to the end of the <see cref="SessionRequestList"/>.
        /// This argument can be a null reference.
        /// </param>    
        /// <returns>The <see cref="SessionRequestList"/> index at which the 
        /// <paramref name="value"/> has been added.</returns>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="SessionRequestList"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>SessionRequestList</b> has a fixed size.</para></exception>    
        /// <remarks>Please refer to <see cref="ArrayList.Add"/> for details.</remarks>
        public virtual int Add(SessionRequest value)
        {
            if (this._count == this._array.Length)
                EnsureCapacity(this._count + 1);

            ++this._version;
            this._array[this._count] = value;
            return this._count++;
        }
コード例 #5
0
        /// <summary>
        /// Inserts a <see cref="SessionRequest"/> element into the 
        /// <see cref="SessionRequestList"/> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="value"/> 
        /// should be inserted.</param>
        /// <param name="value">The <see cref="SessionRequest"/> object
        /// to insert into the <see cref="SessionRequestList"/>.
        /// This argument can be a null reference.
        /// </param>    
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="index"/> is less than zero.</para>
        /// <para>-or-</para>
        /// <para><paramref name="index"/> is greater than <see cref="Count"/>.</para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="SessionRequestList"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>SessionRequestList</b> has a fixed size.</para></exception>    
        /// <remarks>Please refer to <see cref="ArrayList.Insert"/> for details.</remarks>
        public virtual void Insert(int index, SessionRequest value)
        {
            if (index < 0)
                throw new ArgumentOutOfRangeException("index", index, "Argument cannot be negative.");
            if (index > this._count)
                throw new ArgumentOutOfRangeException("index", index, "Argument cannot exceed Count.");

            if (this._count == this._array.Length)
                EnsureCapacity(this._count + 1);

            ++this._version;
            if (index < this._count)
                Array.Copy(this._array, index, this._array, index + 1, this._count - index);

            this._array[index] = value;
            ++this._count;
        }
コード例 #6
0
 /// <summary>
 /// Copies the elements of the <see cref="SessionRequestList"/> to a new
 /// <see cref="Array"/> of <see cref="SessionRequest"/> elements.
 /// </summary>
 /// <returns>A one-dimensional <see cref="Array"/> of <see cref="SessionRequest"/> 
 /// elements containing copies of the elements of the <see cref="SessionRequestList"/>.</returns>
 /// <remarks>Please refer to <see cref="ArrayList.ToArray"/> for details.</remarks>
 public virtual SessionRequest[] ToArray()
 {
     SessionRequest[] array = new SessionRequest[this._count];
     Array.Copy(this._array, array, this._count);
     return array;
 }
コード例 #7
0
 public override bool Contains(SessionRequest value)
 {
     lock (this._root) return this._collection.Contains(value);
 }
コード例 #8
0
 /// <summary>
 /// Copies the entire <see cref="SessionRequestList"/> to a one-dimensional <see cref="Array"/>
 /// of <see cref="SessionRequest"/> elements, starting at the specified index of the target array.
 /// </summary>
 /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the
 /// <see cref="SessionRequest"/> elements copied from the <see cref="SessionRequestList"/>.
 /// The <b>Array</b> must have zero-based indexing.</param>
 /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> 
 /// at which copying begins.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="array"/> is a null reference.</exception>    
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="arrayIndex"/> is less than zero.</exception>    
 /// <exception cref="ArgumentException"><para>
 /// <paramref name="arrayIndex"/> is equal to or greater than the length of <paramref name="array"/>.
 /// </para><para>-or-</para><para>
 /// The number of elements in the source <see cref="SessionRequestList"/> is greater than the
 /// available space from <paramref name="arrayIndex"/> to the end of the destination 
 /// <paramref name="array"/>.</para></exception>
 /// <remarks>Please refer to <see cref="ArrayList.CopyTo"/> for details.</remarks>
 public virtual void CopyTo(SessionRequest[] array, int arrayIndex)
 {
     CheckTargetArray(array, arrayIndex);
     Array.Copy(this._array, 0, array, arrayIndex, this._count);
 }
コード例 #9
0
 public override void AddRange(SessionRequest[] array)
 {
     lock (this._root) this._collection.AddRange(array);
 }
コード例 #10
0
 public override int BinarySearch(SessionRequest value)
 {
     lock (this._root) return this._collection.BinarySearch(value);
 }
コード例 #11
0
 public override int Add(SessionRequest value)
 {
     lock (this._root) return this._collection.Add(value);
 }
コード例 #12
0
 public override void Remove(SessionRequest value)
 {
     throw new NotSupportedException("Read-only collections cannot be modified.");
 }
コード例 #13
0
 public override void CopyTo(SessionRequest[] array)
 {
     this._collection.CopyTo(array);
 }
コード例 #14
0
 /// <summary>
 /// Determines whether the <see cref="SessionRequestList"/>
 /// contains the specified <see cref="SessionRequest"/> element.
 /// </summary>
 /// <param name="value">The <see cref="SessionRequest"/> object
 /// to locate in the <see cref="SessionRequestList"/>.
 /// This argument can be a null reference.
 /// </param>    
 /// <returns><c>true</c> if <paramref name="value"/> is found in the 
 /// <see cref="SessionRequestList"/>; otherwise, <c>false</c>.</returns>
 /// <remarks>Please refer to <see cref="ArrayList.Contains"/> for details.</remarks>
 public virtual bool Contains(SessionRequest value)
 {
     return (IndexOf(value) >= 0);
 }
コード例 #15
0
 public override void CopyTo(SessionRequest[] array, int arrayIndex)
 {
     lock (this._root) this._collection.CopyTo(array, arrayIndex);
 }
コード例 #16
0
 /// <overloads>
 /// Copies the <see cref="SessionRequestList"/> or a portion of it to a one-dimensional array.
 /// </overloads>
 /// <summary>
 /// Copies the entire <see cref="SessionRequestList"/> to a one-dimensional <see cref="Array"/>
 /// of <see cref="SessionRequest"/> elements, starting at the beginning of the target array.
 /// </summary>
 /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the
 /// <see cref="SessionRequest"/> elements copied from the <see cref="SessionRequestList"/>.
 /// The <b>Array</b> must have zero-based indexing.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="array"/> is a null reference.</exception>    
 /// <exception cref="ArgumentException">
 /// The number of elements in the source <see cref="SessionRequestList"/> is greater 
 /// than the available space in the destination <paramref name="array"/>.</exception>
 /// <remarks>Please refer to <see cref="ArrayList.CopyTo"/> for details.</remarks>
 public virtual void CopyTo(SessionRequest[] array)
 {
     CheckTargetArray(array, 0);
     Array.Copy(this._array, array, this._count);
 }
コード例 #17
0
 public override int IndexOf(SessionRequest value)
 {
     lock (this._root) return this._collection.IndexOf(value);
 }
コード例 #18
0
 /// <summary>
 /// Returns the zero-based index of the first occurrence of the specified 
 /// <see cref="SessionRequest"/> in the <see cref="SessionRequestList"/>.
 /// </summary>
 /// <param name="value">The <see cref="SessionRequest"/> object 
 /// to locate in the <see cref="SessionRequestList"/>.
 /// This argument can be a null reference.
 /// </param>    
 /// <returns>
 /// The zero-based index of the first occurrence of <paramref name="value"/> 
 /// in the <see cref="SessionRequestList"/>, if found; otherwise, -1.
 /// </returns>
 /// <remarks>Please refer to <see cref="ArrayList.IndexOf"/> for details.</remarks>
 public virtual int IndexOf(SessionRequest value)
 {
     return Array.IndexOf(this._array, value, 0, this._count);
 }
コード例 #19
0
 public override void Insert(int index, SessionRequest value)
 {
     lock (this._root) this._collection.Insert(index, value);
 }
コード例 #20
0
 /// <summary>
 /// Removes the first occurrence of the specified <see cref="SessionRequest"/>
 /// from the <see cref="SessionRequestList"/>.
 /// </summary>
 /// <param name="value">The <see cref="SessionRequest"/> object
 /// to remove from the <see cref="SessionRequestList"/>.
 /// This argument can be a null reference.
 /// </param>    
 /// <exception cref="NotSupportedException">
 /// <para>The <see cref="SessionRequestList"/> is read-only.</para>
 /// <para>-or-</para>
 /// <para>The <b>SessionRequestList</b> has a fixed size.</para></exception>    
 /// <remarks>Please refer to <see cref="ArrayList.Remove"/> for details.</remarks>
 public virtual void Remove(SessionRequest value)
 {
     int index = IndexOf(value);
     if (index >= 0) RemoveAt(index);
 }
コード例 #21
0
 public override void Remove(SessionRequest value)
 {
     lock (this._root) this._collection.Remove(value);
 }
コード例 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionRequestList"/> class
        /// that contains elements copied from the specified <see cref="SessionRequest"/>
        /// array and that has the same initial capacity as the number of elements copied.
        /// </summary>
        /// <param name="array">An <see cref="Array"/> of <see cref="SessionRequest"/> 
        /// elements that are copied to the new collection.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="array"/> is a null reference.</exception>        
        /// <remarks>Please refer to <see cref="ArrayList(ICollection)"/> for details.</remarks>    
        public SessionRequestList(SessionRequest[] array)
        {
            if (array == null)
                throw new ArgumentNullException("array");

            this._array = new SessionRequest[array.Length];
            AddRange(array);
        }
コード例 #23
0
        /// <summary>
        /// Apply the test requests for a session request.
        /// </summary>
        /// <param name="sessionRequest"> The session request.</param>
        /// <param name="result"> The response buffer result from the safe session.</param>
        private void ApplyRequestTests(SessionRequest sessionRequest, ResponseBuffer result)
        {
            UnitTestItem unitTestItem = sessionRequest.WebUnitTest;
            unitTestItem.Form = sessionRequest.Form;

            CookieCollection cookies = null;

            //int availableTests = this.AvailableTests();
            //bool lastItem = false;
            string requestUrl = sessionRequest.Url.ToString();

            #region Run each test in SessionRequest WebUnitTestItem

            // run each test in Form
            foreach (DictionaryEntry de in unitTestItem.Tests)
            {
                Test test = (Test)de.Value;
                ArrayList values = new ArrayList();

                // get cookies
                cookies = cookieManager.GetCookies(sessionRequest.Url);

                // set current test index
                unitTestItem.SelectedTestIndex = unitTestItem.Tests.IndexOfValue(test);

                // create SessionCommandProcessEventArgs
                SessionCommandProcessEventArgs args = new SessionCommandProcessEventArgs("Applying test '" + test.Name + "' to " + sessionRequest.Url.ToString());
                args.ProcessType = SessionProcessType.TestRequest;

                #region Apply Test
                // --------------------------------------------------------------------------------
                // Process data
                // Html Form Tag
                if ( test.UnitTestDataType == UnitTestDataContainer.HtmlFormTag )
                {
                    // is a form tag
                    // apply test to form
                    HtmlFormTag filledForm = ApplyTestToForm(test, sessionRequest.Form.CloneTag());
                    values = parser.GetArrayList(filledForm, result.HttpBody, updateElementNames);
                }
                // Post Data Hashtable
                if ( test.UnitTestDataType == UnitTestDataContainer.PostDataHashtable )
                {
                    string postdata = ((PostSessionRequest)sessionRequest).PostData;

                    // TODO: Change to PostDataCollection method.
                    // convert post data to hashtable
                    FormConverter converter = new FormConverter();
                    //Hashtable postDataCollection = converter.ConvertPostDataStringHashtable(postdata);
                    PostDataCollection postDataCollection = converter.GetPostDataCollection(postdata);

                    // Applies test to post data hashtable
                    PostDataCollection filledPostData = ApplyTestToPostData(test, postDataCollection.Clone());
                    values = converter.GetArrayList(filledPostData);
                }
                // Cookies
                if ( test.UnitTestDataType == UnitTestDataContainer.Cookies )
                {
                    cookies = ApplyTestToCookies(test, cookies);
                }
                // Url
                if( test.UnitTestDataType == UnitTestDataContainer.NoPostData )
                {
                    // a url test
                    requestUrl = ApplyTestToUrl(test, WebServerUriType.Normal,sessionRequest.Url).ToString();
                }
                // -----------------------------------------------------------------------------------
                #endregion

                if ( (test.UnitTestDataType == UnitTestDataContainer.HtmlFormTag ) || ( test.UnitTestDataType == UnitTestDataContainer.PostDataHashtable ) )
                {
                    // Set post data for report
                    test.Arguments.PostData = ConvertToPostDataString(values);
                    args.Detail = "Posted Data:" + test.Arguments.PostData;
                }
                if ( test.UnitTestDataType == UnitTestDataContainer.NoPostData )
                {
                    args.Detail = "Url query:" + requestUrl;
                }
                if ( test.UnitTestDataType == UnitTestDataContainer.Cookies )
                {
                    StringBuilder cookieQuery = new StringBuilder();

                    foreach ( Cookie cky in cookies )
                    {
                        cookieQuery.Append("Name:" + cky.Name);
                        cookieQuery.Append(", ");
                        cookieQuery.Append("Value:" + cky.Value);
                        cookieQuery.Append(";");
                    }

                    args.Detail = "Cookie:" + cookieQuery.ToString();
                }

            //				// set last item flag
            //				if ( availableTests == 1)
            //				{
            //					lastItem = true;
            //				}

                // display the current processing
                this.DisplaySessionProcessEvent(this,args);

                // clone test item and set last item value
                HttpState httpRequestState = new HttpState();
                httpRequestState.TestItem = unitTestItem.Clone();
                //httpRequestState.IsLastItem = lastItem;

                // http settings
                HttpProperties httpSettings = null;
                if ( sessionRequest.RequestHttpSettings == null )
                {
                    httpSettings = unitTestGetRequest.ClientSettings;
                }
                else
                {
                    httpSettings = sessionRequest.RequestHttpSettings;
                }

                if ( sessionRequest.RequestType == HttpRequestType.GET )
                {
                    // get request
                    this.StartGetRequest(unitTestGetRequest,
                        requestUrl,
                        null,
                        cookies,
                        httpSettings,
                        httpRequestState);
                }
                else  if ( sessionRequest.RequestType == HttpRequestType.POST )
                {
                    // post request
                    this.StartPostRequest(unitTestPostRequest,
                        requestUrl,
                        values,
                        cookies,
                        httpSettings,
                        httpRequestState);
                }

                //availableTests--;
            }
            #endregion
        }