Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / MonoRail / Castle.MonoRail.Framework.Views.NVelocity.Tests / SmartController2TestCase.cs
blob47e1043509d6e7bac1e3ddfe6fac4307cb61d1ad
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.Views.NVelocity.Tests
17 using System;
18 using Castle.MonoRail.Framework.Tests;
19 using NUnit.Framework;
21 using Castle.MonoRail.TestSupport;
23 [TestFixture]
24 public class SmartController2TestCase : AbstractTestCase
26 [Test]
27 public void SimpleBindArray()
29 DoPost("smart2/SimpleBindArray.rails");
30 AssertReplyEqualTo("incoming 0");
32 DoGet("smart2/SimpleBindArray.rails");
33 AssertReplyEqualTo("incoming 0");
35 DoGet("smart2/SimpleBindArray.rails", "orders[0].Name=hammett", "orders[1].Name=hamilton");
36 AssertReplyEqualTo("incoming 2");
39 [Test]
40 public void SimpleBind()
42 DoPost("smart2/SimpleBind.rails");
43 String expected = "incoming 0 0";
44 AssertReplyEqualTo(expected);
46 DoPost("smart2/SimpleBind.rails", "order.name=hammett", "order.itemcount=11", "order.price=20");
47 expected = "incoming hammett 11 20";
48 AssertReplyEqualTo(expected);
50 // Double check
51 DoPost("smart2/SimpleBind.rails", "order.name=hammett", "order.itemcount=11", "order.price=20");
52 expected = "incoming hammett 11 20";
53 AssertReplyEqualTo(expected);
55 DoGet("smart2/SimpleBind.rails", "order.name=hammett", "order.itemcount=11", "order.price=20");
56 expected = "incoming hammett 11 20";
57 AssertReplyEqualTo(expected);
59 DoGet("smart2/SimpleBind.rails", "order.name=hammett");
60 expected = "incoming hammett 0 0";
61 AssertReplyEqualTo(expected);
64 [Test]
65 public void ComplexBind()
67 DoGet( "smart2/ComplexBind.rails", "order.name=hammett", "order.itemcount=11", "order.price=20", "person.id=1", "person.contact.email=x", "person.contact.phone=y" );
68 String expected = "incoming hammett 11 20 1 x y";
70 AssertReplyEqualTo( expected );
73 [Test]
74 public void ComplexBindExcludePrice()
76 DoGet( "smart2/ComplexBindExcludePrice.rails", "order.name=hammett", "order.itemcount=11", "order.price=20", "person.id=1", "person.contact.email=x", "person.contact.phone=y" );
77 // This still includes zero in place of price due to
78 // the ToString() method of the domain object and price being of type float
79 String expected = "incoming hammett 11 0 1 x y";
81 AssertReplyEqualTo( expected );
84 [Test]
85 public void ComplexBindExcludeName()
87 DoGet( "smart2/ComplexBindExcludeName.rails", "order.name=hammett", "order.itemcount=11", "order.price=20", "person.id=1", "person.contact.email=x", "person.contact.phone=y" );
88 // This includes an extra space because of the ToString()
89 // method of the domain object and the custom String.Format it contains.
90 String expected = "incoming 11 20 1 x y";
92 AssertReplyEqualTo( expected );
95 [Test]
96 public void ComplexBindWithPrefix()
98 DoGet("smart2/ComplexBindWithPrefix.rails", "order.name=hammett", "order.itemcount=11", "order.price=20", "person.id=1", "person.contact.email=x", "person.contact.phone=y");
99 String expected = "incoming hammett 11 20 1 x y";
101 AssertReplyEqualTo(expected);
104 [Test]
105 public void FillingBehavior1()
107 System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
109 DoGet("smart2/FillingBehavior.rails", "abc.name=someone", "abc.date1day=11", "abc.date1month=10", "abc.date1year=2005");
111 String expected = "incoming someone " + new DateTime( 2005, 10, 11 ).ToShortDateString() + " " +
112 DateTime.Now.AddDays(1).ToShortDateString();
114 AssertReplyEqualTo(expected);
117 [Test]
118 public void FillingBehavior2()
120 System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
122 DoGet("smart2/FillingBehavior.rails");
124 String expected = "incoming hammett " +
125 DateTime.Now.ToShortDateString() + " " + DateTime.Now.AddDays(1).ToShortDateString();
127 AssertReplyEqualTo(expected);
130 [Test]
131 public void NullableAndDataBind()
133 DoGet("smart2/NullableConversion2.rails", "mov.name=hammett", "mov.amount=11");
134 String expected = "incoming hammett 11";
136 AssertReplyEqualTo(expected);
139 [Test]
140 public void NullableAndDataBind2()
142 DoGet("smart2/NullableConversion2.rails", "mov.name=hammett");
143 String expected = "incoming hammett ";
145 AssertReplyEqualTo(expected);
148 [Test]
149 public void ArrayBinding1()
151 DoGet("smart2/ArrayBinding.rails", "user.name=hammett", "user.roles=1", "user.roles=2", "user.permissions=10", "user.permissions=11");
152 String expected = "User hammett 2 2 1 2 10 11";
154 AssertReplyEqualTo(expected);
157 [Test]
158 public void BugReportedOnForum1()
160 DoGet("smart2/CalculateUtilizationByDay.rails", "tp1.Hour=1", "tp1.Minute=2", "tp1.Second=3", "tp2.Hour=10", "tp2.Minute=20", "tp2.Second=30");
161 String expected = " 1:2:3 10:20:30 ";
163 AssertReplyEqualTo(expected);