Selaa lähdekoodia

store HttpStatusCode in WebTest.Response

svn path=/trunk/mcs/; revision=68656
Andrew Skiba 19 vuotta sitten
vanhempi
sitoutus
ba92e7ea1d

+ 5 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/BaseRequest.cs

@@ -157,6 +157,8 @@ namespace MonoTests.SystemWeb.Framework
 			wr.Close ();
 			Response r = new Response ();
 			r.Body = wr.ToString ();
+			r.StatusCode = br.StatusCode;
+			r.StatusDescription = br.StatusDescription;
 			return r;
 		}
 
@@ -170,6 +172,9 @@ namespace MonoTests.SystemWeb.Framework
 		public virtual Response ExtractResponse (WebResponse response)
 		{
 			Response r = new Response ();
+			r.StatusCode = ((HttpWebResponse)response).StatusCode;
+			r.StatusDescription = ((HttpWebResponse) response).StatusDescription;
+				
 			byte [] b = new byte [response.ContentLength];
 			using (Stream s = response.GetResponseStream ()) {
 				StreamReader sr = new StreamReader(s);

+ 25 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/BaseWorkerRequest.cs

@@ -4,6 +4,7 @@ using System.Web.Hosting;
 using System.IO;
 using System.Collections;
 using System.Reflection;
+using System.Net;
 
 namespace MonoTests.SystemWeb.Framework
 {
@@ -54,5 +55,29 @@ namespace MonoTests.SystemWeb.Framework
 					foreignData[type] = value;
 			}
 		}
+
+		HttpStatusCode _statusCode;
+		string _statusDescription;
+		/// <summary>
+		/// Overriden to store the status code.
+		/// </summary>
+		/// <param name="statusCode"></param>
+		/// <param name="statusDescription"></param>
+		public override void SendStatus (int statusCode, string statusDescription)
+		{
+			_statusCode = (HttpStatusCode) statusCode;
+			_statusDescription = statusDescription;
+			base.SendStatus (statusCode, statusDescription);
+		}
+
+		internal HttpStatusCode StatusCode
+		{
+			get { return _statusCode; }
+		}
+
+		internal string StatusDescription
+		{
+			get { return _statusDescription; }
+		}
 	}
 }

+ 27 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Response.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Net;
 
 namespace MonoTests.SystemWeb.Framework
 {
@@ -11,6 +12,8 @@ namespace MonoTests.SystemWeb.Framework
 	public class Response
 	{
 		string _body;
+		HttpStatusCode _statusCode;
+		string _statusDescription;
 		/// <summary>
 		/// Get the response body.
 		/// </summary>
@@ -22,5 +25,29 @@ namespace MonoTests.SystemWeb.Framework
 #endif
 			set { _body = value; }
 		}
+
+		/// <summary>
+		/// Get the HTTP status code of the response
+		/// </summary>
+		public HttpStatusCode StatusCode
+		{
+			get { return _statusCode; }
+#if NET_2_0
+			internal
+#endif
+			set { _statusCode = value; }
+		}
+
+		/// <summary>
+		/// Get the HTTP status description of the response
+		/// </summary>
+		public string StatusDescription
+		{
+			get { return _statusDescription; }
+#if NET_2_0
+			internal
+#endif
+			set { _statusDescription = value; }
+		}
 	}
 }