Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / MonoRail / Castle.MonoRail.TestSupport / TestResponse.cs
blob834f8c71d30fb1028a6ce43a4dca1269f76755df
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.TestSupport
17 using System;
18 using System.Net;
19 using System.Web;
20 using System.Collections;
21 using Castle.MonoRail.Framework.Internal.Test;
23 [Serializable]
24 public class TestResponse : MarshalByRefObject
26 private int statusCode;
27 private String statusDescription;
28 private IDictionary propertyBag;
29 private IDictionary flash;
30 private IDictionary session;
31 private IDictionary headers = new Hashtable();
32 private CookieContainer cookies = new CookieContainer();
34 public TestResponse()
38 public int StatusCode
40 get { return statusCode; }
41 set { statusCode = value; }
44 public string StatusDescription
46 get { return statusDescription; }
47 set { statusDescription = value; }
50 public IDictionary Headers
52 get { return headers; }
55 public CookieContainer Cookies
57 get { return cookies; }
60 public IDictionary PropertyBag
62 get { return propertyBag; }
65 public IDictionary Flash
67 get { return flash; }
70 public IDictionary Session
72 get { return session; }
75 protected internal void Complete()
77 foreach(DictionaryEntry entry in headers)
79 String name = entry.Key.ToString();
81 if ("Set-Cookie".Equals(name))
83 if (entry.Value is IList)
85 foreach(String value in (IList) entry.Value)
87 cookies.SetCookies(new Uri("http://localhost"), value);
90 else
92 try
94 cookies.SetCookies(new Uri("http://localhost"), entry.Value.ToString());
96 catch(Exception ex)
98 Console.WriteLine(ex.ToString());
102 break;
106 HttpContext context = TestContextHolder.Context;
108 flash = (IDictionary) context.Items["mr.flash"];
109 session = (IDictionary) context.Items["mr.session"];
110 propertyBag = (IDictionary) context.Items["mr.propertybag"];