Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / WatirTestCases / ARSupport / personuser.rb
blob846e43afe50a7f9f628761e5dd88c4327cb47248
1 ## Copyright 2004-2007 Castle Project - http://www.castleproject.org/\r
2 ## \r
3 ## Licensed under the Apache License, Version 2.0 (the "License");\r
4 ## you may not use this file except in compliance with the License.\r
5 ## You may obtain a copy of the License at\r
6 ##\r
7 ##     http://www.apache.org/licenses/LICENSE-2.0\r
8 ## \r
9 ## Unless required by applicable law or agreed to in writing, software\r
10 ## distributed under the License is distributed on an "AS IS" BASIS,\r
11 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 ## See the License for the specific language governing permissions and\r
13 ## limitations under the License.\r
15 require '../common'\r
17 class PersonUser\r
19         class << self\r
21                 include Test::Unit::Assertions\r
23                 def create(ie, first, middle, last, username, password)\r
25                         ie.goto("#{$base_url}/personuser/new.castle")\r
26                         \r
27                         send_create(ie, first, middle, last, username, password)\r
28                 end\r
30                 def edit(ie, id, first, middle, last, username, password)\r
32                         ie.goto("#{$base_url}/personuser/edit.castle?id=#{id}")\r
33                         \r
34                         send_edit(ie, id, first, middle, last, username, password)\r
35                 end\r
36                 \r
37                 def delete(ie, id)\r
39                         ie.goto("#{$base_url}/personuser/removeconfirm.castle?id=#{id}")\r
41                         fail('Looks like removeConfirm.castle didnt load instance') unless ie.contains_text("Confirm removal of #{id}?")\r
42                         \r
43                         ie.button(:id, 'button').click\r
45                         fail('Error removing instance') unless ie.contains_text('Removed')\r
46                         fail('Unexpected exception') if ie.contains_text('Exception')\r
47                         \r
48                 end\r
49                 \r
50                 private\r
51                 \r
52                 def send_create(ie, first, middle, last, username, password)\r
53                 \r
54                         ie.text_field(:id, "user_first").set(first)\r
55                         ie.text_field(:id, "user_middle").set(middle)\r
56                         ie.text_field(:id, "user_last").set(last)\r
57                         ie.text_field(:id, "user_username").set(username)\r
58                         ie.text_field(:id, "user_password").set(password)\r
59                         \r
60                         ie.button(:id, 'insertbutton').click\r
62                         # Check for errors\r
63                         \r
64                         fail('There were databind errors') if ie.contains_text('binding error')\r
65                         fail('Unexpected exception') if ie.contains_text('Exception')\r
66                         \r
67                         assert_equal(first, ie.span(:id, 'first').text)\r
68                         assert_equal(middle, ie.span(:id, 'middle').text)\r
69                         assert_equal(last, ie.span(:id, 'last').text)\r
70                         assert_equal(username, ie.span(:id, 'username').text)\r
71                         assert_equal(password, ie.span(:id, 'password').text)\r
73                         # returns new created id\r
74                         \r
75                         ie.span(:id, 'newid').text\r
76                 end\r
77                 \r
78                 def send_edit(ie, id, first, middle, last, username, password)\r
79                 \r
80                         ie.text_field(:id, "user_first").set(first)\r
81                         ie.text_field(:id, "user_middle").set(middle)\r
82                         ie.text_field(:id, "user_last").set(last)\r
83                         ie.text_field(:id, "user_username").set(username)\r
84                         ie.text_field(:id, "user_password").set(password)\r
85                         \r
86                         ie.button(:id, 'updatebutton').click\r
88                         # Check for errors\r
89                         \r
90                         fail('There were databind errors') if ie.contains_text('binding error')\r
91                         fail('Unexpected exception') if ie.contains_text('Exception')\r
92                         \r
93                         assert_equal(first, ie.span(:id, 'first').text)\r
94                         assert_equal(middle, ie.span(:id, 'middle').text)\r
95                         assert_equal(last, ie.span(:id, 'last').text)\r
96                         assert_equal(username, ie.span(:id, 'username').text)\r
97                         assert_equal(password, ie.span(:id, 'password').text)\r
98                 end\r
100         end\r
102 end\r