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
;
23 public class BasicFunctionalityTestCase
: AbstractTestCase
26 public void SimpleControllerAction()
28 DoGet("home/index.rails");
32 AssertReplyEqualTo( "My View contents for Home\\Index" );
36 public void RenderView()
38 DoGet("home/welcome.rails");
42 AssertReplyEqualTo( "Contents for heyhello View" );
48 DoGet("home/flash1.rails");
52 AssertFlashEntryEquals("errormessage", "Some error");
56 public void Redirect()
58 DoGet("home/redirectAction.rails");
62 AssertRedirectedTo( "/home/index.rails" );
66 public void RedirectForArea()
68 DoGet("home/redirectforotherarea.rails");
72 AssertRedirectedTo( "/subarea/home/index.rails" );
76 public void PropertyBagNoFieldSetting()
78 DoGet("home/bag.rails");
82 AssertPropertyBagContains( "CustomerName" );
83 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
84 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
88 public void PropertyBagUsingFieldSetting()
90 DoGet("home/bag2.rails");
94 AssertPropertyBagContains( "CustomerName" );
95 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
96 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
100 public void CreateCookie()
102 DoGet("cookies/addcookie.rails");
106 AssertReplyEqualTo( @"My View contents for Cookies\Index" );
108 // One of the cookies will be the asp.net used by the flash property
109 // Assert.AreEqual( 3, Response.Cookies.Count );
111 AssertHasCookie( "cookiename" );
112 AssertHasCookie( "cookiename2" );
113 AssertCookieValueEqualsTo( "cookiename", "value" );
114 AssertCookieValueEqualsTo( "cookiename2", "value2" );
118 public void CreateCookieRedirect()
120 DoGet("cookies/AddCookieRedirect.rails");
124 AssertRedirectedTo("/cookies/index.rails");
126 AssertCookieValueEqualsTo("cookiename", "value");
130 public void CreateCookieExpirationRedirect()
132 DoGet("cookies/AddCookieExpirationRedirect.rails");
136 AssertRedirectedTo("/cookies/index.rails");
138 DateTime twoWeeks
= DateTime
.Now
.Add(new TimeSpan(14, 0, 0, 0));
140 AssertCookieExpirationEqualsTo("cookiename2", twoWeeks
);
141 AssertCookieValueEqualsTo("cookiename2", "value");
145 public void CreateCookieExpiration()
147 DoGet("cookies/AddCookieExpiration.rails");
151 AssertReplyEqualTo(@"My View contents for Cookies\Index");
153 DateTime twoWeeks
= DateTime
.Now
.Add(new TimeSpan(14, 0, 0, 0));
155 AssertCookieExpirationEqualsTo("cookiename2", twoWeeks
);
156 AssertCookieValueEqualsTo("cookiename2", "value");
160 public void FormPostSmartDispatcher()
162 DoPost( "registration/posthere.rails", "p1=foo", "p2=123" );
166 AssertReplyContains( "param1=foo" );
167 AssertReplyContains( "param2=123" );
171 public void OverloadNullSmartDispatcher()
173 DoPost("registration/posthere.rails", "p1=foo", "p2=123");
177 AssertReplyContains("param1=foo");
178 AssertReplyContains("param2=123");