Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / BasicFunctionalityTestCase.cs
blob4162ae12eaee04accc2cf64a5a136a015eb96339
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;
22 [TestFixture]
23 public class BasicFunctionalityTestCase : AbstractTestCase
25 [Test]
26 public void SimpleControllerAction()
28 DoGet("home/index.rails");
30 AssertSuccess();
32 AssertReplyEqualTo( "My View contents for Home\\Index" );
35 [Test]
36 public void RenderView()
38 DoGet("home/welcome.rails");
40 AssertSuccess();
42 AssertReplyEqualTo( "Contents for heyhello View" );
45 [Test]
46 public void Flash()
48 DoGet("home/flash1.rails");
50 AssertSuccess();
52 AssertFlashEntryEquals("errormessage", "Some error");
55 [Test]
56 public void Redirect()
58 DoGet("home/redirectAction.rails");
60 AssertSuccess();
62 AssertRedirectedTo( "/home/index.rails" );
65 [Test]
66 public void RedirectForArea()
68 DoGet("home/redirectforotherarea.rails");
70 AssertSuccess();
72 AssertRedirectedTo( "/subarea/home/index.rails" );
75 [Test]
76 public void PropertyBagNoFieldSetting()
78 DoGet("home/bag.rails");
80 AssertSuccess();
82 AssertPropertyBagContains( "CustomerName" );
83 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
84 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
87 [Test]
88 public void PropertyBagUsingFieldSetting()
90 DoGet("home/bag2.rails");
92 AssertSuccess();
94 AssertPropertyBagContains( "CustomerName" );
95 AssertPropertyBagEntryEquals( "CustomerName", "hammett" );
96 AssertReplyEqualTo( "\r\nCustomer is hammett\r\n<br>\r\n123" );
99 [Test]
100 public void CreateCookie()
102 DoGet("cookies/addcookie.rails");
104 AssertSuccess();
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" );
117 [Test]
118 public void CreateCookieRedirect()
120 DoGet("cookies/AddCookieRedirect.rails");
122 AssertSuccess();
124 AssertRedirectedTo("/cookies/index.rails");
126 AssertCookieValueEqualsTo("cookiename", "value");
129 [Test]
130 public void CreateCookieExpirationRedirect()
132 DoGet("cookies/AddCookieExpirationRedirect.rails");
134 AssertSuccess();
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");
144 [Test]
145 public void CreateCookieExpiration()
147 DoGet("cookies/AddCookieExpiration.rails");
149 AssertSuccess();
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");
159 [Test]
160 public void FormPostSmartDispatcher()
162 DoPost( "registration/posthere.rails", "p1=foo", "p2=123" );
164 AssertSuccess();
166 AssertReplyContains( "param1=foo" );
167 AssertReplyContains( "param2=123" );
170 [Test]
171 public void OverloadNullSmartDispatcher()
173 DoPost("registration/posthere.rails", "p1=foo", "p2=123");
175 AssertSuccess();
177 AssertReplyContains("param1=foo");
178 AssertReplyContains("param2=123");