Applied Patrick Earl's patch, adding event ModelCreated that allows to re-configure...
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / BasicFunctionalityTestCase.cs
blob1102ff3cc1464f94dabab3426c763ccfe6617077
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.Framework.Tests
17 using System;
19 using NUnit.Framework;
21 using Castle.MonoRail.TestSupport;
24 [TestFixture]
25 public class BasicFunctionalityTestCase : AbstractTestCase
27 [Test]
28 public void SimpleControllerAction()
30 DoGet("home/index.rails");
32 AssertSuccess();
34 AssertReplyEqualTo( "My View contents for Home\\Index" );
37 [Test]
38 public void RenderView()
40 DoGet("home/welcome.rails");
42 AssertSuccess();
44 AssertReplyEqualTo( "Contents for heyhello View" );
47 [Test]
48 public void Flash()
50 DoGet("home/flash1.rails");
52 AssertSuccess();
54 AssertFlashEntryEquals("errormessage", "Some error");
57 [Test]
58 public void Redirect()
60 DoGet("home/redirectAction.rails");
62 AssertSuccess();
64 AssertRedirectedTo( "/home/index.rails" );
67 [Test]
68 public void RedirectForArea()
70 DoGet("home/redirectforotherarea.rails");
72 AssertSuccess();
74 AssertRedirectedTo( "/subarea/home/index.rails" );
77 [Test]
78 public void PropertyBagNoFieldSetting()
80 DoGet("home/bag.rails");
82 AssertSuccess();
84 AssertPropertyBagContains( "CustomerName" );
85 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
86 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
89 [Test]
90 public void PropertyBagUsingFieldSetting()
92 DoGet("home/bag2.rails");
94 AssertSuccess();
96 AssertPropertyBagContains( "CustomerName" );
97 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
98 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
101 [Test]
102 public void CreateCookie()
104 DoGet("cookies/addcookie.rails");
106 AssertSuccess();
108 AssertReplyEqualTo( @"My View contents for Cookies\Index" );
110 /// One of the cookies will be the asp.net used by the flash property
111 ///Assert.AreEqual( 3, Response.Cookies.Count );
113 AssertHasCookie( "cookiename" );
114 AssertHasCookie( "cookiename2" );
115 AssertCookieValueEqualsTo( "cookiename", "value" );
116 AssertCookieValueEqualsTo( "cookiename2", "value2" );
119 [Test]
120 public void CreateCookieRedirect()
122 DoGet("cookies/AddCookieRedirect.rails");
124 AssertSuccess();
126 AssertRedirectedTo("/cookies/index.rails");
128 AssertCookieValueEqualsTo("cookiename", "value");
131 [Test]
132 public void CreateCookieExpirationRedirect()
134 DoGet("cookies/AddCookieExpirationRedirect.rails");
136 AssertSuccess();
138 AssertRedirectedTo("/cookies/index.rails");
140 DateTime twoWeeks = DateTime.Now.Add(new TimeSpan(14, 0, 0, 0));
142 AssertCookieExpirationEqualsTo("cookiename2", twoWeeks);
143 AssertCookieValueEqualsTo("cookiename2", "value");
146 [Test]
147 public void CreateCookieExpiration()
149 DoGet("cookies/AddCookieExpiration.rails");
151 AssertSuccess();
153 AssertReplyEqualTo(@"My View contents for Cookies\Index");
155 DateTime twoWeeks = DateTime.Now.Add(new TimeSpan(14, 0, 0, 0));
157 AssertCookieExpirationEqualsTo("cookiename2", twoWeeks);
158 AssertCookieValueEqualsTo("cookiename2", "value");
161 [Test]
162 public void FormPostSmartDispatcher()
164 DoPost( "registration/posthere.rails", "p1=foo", "p2=123" );
166 AssertSuccess();
168 AssertReplyContains( "param1=foo" );
169 AssertReplyContains( "param2=123" );
172 [Test]
173 public void OverloadNullSmartDispatcher()
175 DoPost("registration/posthere.rails", "p1=foo", "p2=123");
177 AssertSuccess();
179 AssertReplyContains("param1=foo");
180 AssertReplyContains("param2=123");