1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
19 using NUnit
.Framework
;
21 using Castle
.MonoRail
.TestSupport
;
25 public class BasicFunctionalityTestCase
: AbstractTestCase
28 public void SimpleControllerAction()
30 DoGet("home/index.rails");
34 AssertReplyEqualTo( "My View contents for Home\\Index" );
38 public void RenderView()
40 DoGet("home/welcome.rails");
44 AssertReplyEqualTo( "Contents for heyhello View" );
50 DoGet("home/flash1.rails");
54 AssertFlashEntryEquals("errormessage", "Some error");
58 public void Redirect()
60 DoGet("home/redirectAction.rails");
64 AssertRedirectedTo( "/home/index.rails" );
68 public void RedirectForArea()
70 DoGet("home/redirectforotherarea.rails");
74 AssertRedirectedTo( "/subarea/home/index.rails" );
78 public void PropertyBagNoFieldSetting()
80 DoGet("home/bag.rails");
84 AssertPropertyBagContains( "CustomerName" );
85 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
86 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
90 public void PropertyBagUsingFieldSetting()
92 DoGet("home/bag2.rails");
96 AssertPropertyBagContains( "CustomerName" );
97 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
98 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
102 public void CreateCookie()
104 DoGet("cookies/addcookie.rails");
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" );
120 public void CreateCookieRedirect()
122 DoGet("cookies/AddCookieRedirect.rails");
126 AssertRedirectedTo("/cookies/index.rails");
128 AssertCookieValueEqualsTo("cookiename", "value");
132 public void CreateCookieExpirationRedirect()
134 DoGet("cookies/AddCookieExpirationRedirect.rails");
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");
147 public void CreateCookieExpiration()
149 DoGet("cookies/AddCookieExpiration.rails");
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");
162 public void FormPostSmartDispatcher()
164 DoPost( "registration/posthere.rails", "p1=foo", "p2=123" );
168 AssertReplyContains( "param1=foo" );
169 AssertReplyContains( "param2=123" );
173 public void OverloadNullSmartDispatcher()
175 DoPost("registration/posthere.rails", "p1=foo", "p2=123");
179 AssertReplyContains("param1=foo");
180 AssertReplyContains("param2=123");