1 // Copyright 2004-2008 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
.Controllers
18 using NUnit
.Framework
;
21 public class AccessibleThroughAttributeTestCase
24 public void ForHttpMethod_WhenOnlyGetIsAllowedAndPostIsTried_IsFalse()
26 AccessibleThroughAttribute attrib
= new AccessibleThroughAttribute(Verb
.Get
);
27 Assert
.IsFalse(attrib
.ForHttpMethod(Verb
.Post
));
31 public void ForHttpMethod_WhenOnlyPostIsAllowedAndGetIsTried_IsFalse()
33 AccessibleThroughAttribute attrib
= new AccessibleThroughAttribute(Verb
.Post
);
34 Assert
.IsFalse(attrib
.ForHttpMethod(Verb
.Get
));
38 public void ForHttpMethod_WhenGetIsAllowedAndGetIsTried_IsTrue()
40 AccessibleThroughAttribute attrib
= new AccessibleThroughAttribute(Verb
.Get
);
41 Assert
.IsTrue(attrib
.ForHttpMethod(Verb
.Get
));
45 public void ForHttpMethod_WhenPostIsAllowedAndPostIsTried_IsTrue()
47 AccessibleThroughAttribute attrib
= new AccessibleThroughAttribute(Verb
.Post
);
48 Assert
.IsTrue(attrib
.ForHttpMethod(Verb
.Post
));
52 public void ForHttpMethod_WhenPostAndGetIsAllowedAndPostIsTried_IsTrue()
54 AccessibleThroughAttribute attrib
= new AccessibleThroughAttribute(Verb
.Post
| Verb
.Get
);
55 Assert
.IsTrue(attrib
.ForHttpMethod(Verb
.Post
));
59 public void ForHttpMethod_WhenPostAndGetIsAllowedAndGetIsTried_IsTrue()
61 AccessibleThroughAttribute attrib
= new AccessibleThroughAttribute(Verb
.Post
| Verb
.Get
);
62 Assert
.IsTrue(attrib
.ForHttpMethod(Verb
.Get
));
66 public void ForHttpMethod_WhenPostAndGetIsAllowedAndDeleteIsTried_IsFalse()
68 AccessibleThroughAttribute attrib
= new AccessibleThroughAttribute(Verb
.Post
| Verb
.Get
);
69 Assert
.IsFalse(attrib
.ForHttpMethod(Verb
.Delete
));
73 public void HttpMethodToVerb_WithSingleMethod_ConvertsToVerb()
75 Assert
.AreEqual(Verb
.Get
, AccessibleThroughAttribute
.HttpMethodToVerb("GET"));
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");