Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / Controllers / AccessibleThroughTestCase.cs
blobb20c569342e69ca4fca7648928f944aacb675970
1 // Copyright 2004-2008 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.Controllers
17 using System;
18 using NUnit.Framework;
20 [TestFixture]
21 public class AccessibleThroughAttributeTestCase
23 [Test]
24 public void ForHttpMethod_WhenOnlyGetIsAllowedAndPostIsTried_IsFalse()
26 AccessibleThroughAttribute attrib = new AccessibleThroughAttribute(Verb.Get);
27 Assert.IsFalse(attrib.ForHttpMethod(Verb.Post));
30 [Test]
31 public void ForHttpMethod_WhenOnlyPostIsAllowedAndGetIsTried_IsFalse()
33 AccessibleThroughAttribute attrib = new AccessibleThroughAttribute(Verb.Post);
34 Assert.IsFalse(attrib.ForHttpMethod(Verb.Get));
37 [Test]
38 public void ForHttpMethod_WhenGetIsAllowedAndGetIsTried_IsTrue()
40 AccessibleThroughAttribute attrib = new AccessibleThroughAttribute(Verb.Get);
41 Assert.IsTrue(attrib.ForHttpMethod(Verb.Get));
44 [Test]
45 public void ForHttpMethod_WhenPostIsAllowedAndPostIsTried_IsTrue()
47 AccessibleThroughAttribute attrib = new AccessibleThroughAttribute(Verb.Post);
48 Assert.IsTrue(attrib.ForHttpMethod(Verb.Post));
51 [Test]
52 public void ForHttpMethod_WhenPostAndGetIsAllowedAndPostIsTried_IsTrue()
54 AccessibleThroughAttribute attrib = new AccessibleThroughAttribute(Verb.Post | Verb.Get);
55 Assert.IsTrue(attrib.ForHttpMethod(Verb.Post));
58 [Test]
59 public void ForHttpMethod_WhenPostAndGetIsAllowedAndGetIsTried_IsTrue()
61 AccessibleThroughAttribute attrib = new AccessibleThroughAttribute(Verb.Post | Verb.Get);
62 Assert.IsTrue(attrib.ForHttpMethod(Verb.Get));
65 [Test]
66 public void ForHttpMethod_WhenPostAndGetIsAllowedAndDeleteIsTried_IsFalse()
68 AccessibleThroughAttribute attrib = new AccessibleThroughAttribute(Verb.Post | Verb.Get);
69 Assert.IsFalse(attrib.ForHttpMethod(Verb.Delete));
72 [Test]
73 public void HttpMethodToVerb_WithSingleMethod_ConvertsToVerb()
75 Assert.AreEqual(Verb.Get, AccessibleThroughAttribute.HttpMethodToVerb("GET"));
78 [Test]
79 public void HttpMethodToVerb_WithMultipleMethods_ConvertsToVerb()
81 Assert.AreEqual(Verb.Get | Verb.Post, AccessibleThroughAttribute.HttpMethodToVerb("GET, POST"));
84 [Test, ExpectedException(typeof(ArgumentException))]
85 public void HttpMethodToVerb_WhenInvalidVerbUsed_Throws()
87 AccessibleThroughAttribute.HttpMethodToVerb("GOOSE");
88 Assert.Fail();