Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / WatirTestCases / ARSupport / account.rb
blobcfbb2894a84a4869974daaae3785ac772e9beff8
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 Account\r
19         class << self\r
21                 include Test::Unit::Assertions\r
23                 def create(ie, name, email, password, confirmation, prod_lic_id, *permissions)\r
25                         ie.goto("#{$base_url}/account/new.castle")\r
26                         \r
27                         send_create(ie, name, email, password, confirmation, prod_lic_id, permissions)\r
28                 end\r
30                 def create2(ie, name, email, password, confirmation, prod_lic_id, *permissions)\r
32                         ie.goto("#{$base_url}/account/new2.castle")\r
34                         send_create(ie, name, email, password, confirmation, prod_lic_id, permissions)\r
35                 end\r
36                 \r
37                 def edit(ie, id, name, email, password, confirmation, prod_lic_id, *permissions)\r
39                         ie.goto("#{$base_url}/account/edit.castle?id=#{id}")\r
40                         \r
41                         send_edit(ie, id, name, email, password, confirmation, prod_lic_id, permissions)\r
42                 end\r
43                 \r
44                 def delete(ie, id)\r
46                         ie.goto("#{$base_url}/account/removeconfirm.castle?id=#{id}")\r
48                         fail('Looks like removeConfirm.castle didnt load instance') unless ie.contains_text("Confirm removal of #{id}?")\r
49                         \r
50                         ie.button(:id, 'button').click\r
52                         fail('Error removing instance') unless ie.contains_text('Removed')\r
53                         fail('Unexpected exception') if ie.contains_text('Exception')\r
54                         \r
55                 end\r
56                 \r
57                 private\r
58                 \r
59                 def send_create(ie, name, email, password, confirmation, prod_lic_id, permissions)\r
60                 \r
61                         ie.text_field(:id, "account_name").set(name)\r
62                         ie.text_field(:id, "account_email").set(email)\r
63                         ie.text_field(:id, "account_password").set(password)\r
64                         ie.text_field(:id, "account_confirmationpassword").set(confirmation)\r
65                         ie.select_list(:id, "account_ProductLicense_id").select_value(prod_lic_id.to_s)\r
66                         \r
67                         permissions.each { |value|\r
68                                 ie.checkbox(:id, 'account_permissions', value.to_s).set\r
69                         }\r
70                         \r
71                         ie.button(:id, 'insertbutton').click\r
73                         # Check for errors\r
74                         \r
75                         fail('There were databind errors') if ie.contains_text('binding error')\r
76                         fail('Unexpected exception') if ie.contains_text('Exception')\r
77                         \r
78                         assert_equal(name, ie.span(:id, 'name').text)\r
79                         assert_equal(email, ie.span(:id, 'email').text)\r
80                         assert_equal(password, ie.span(:id, 'password').text)\r
81                         assert_equal(prod_lic_id, ie.span(:id, 'pl').text) unless prod_lic_id == "0"\r
82                         assert_equal(permissions.sort!, ie.span(:id, 'permissions').text.split(',').sort!)\r
84                         # returns new created id\r
85                         \r
86                         ie.span(:id, 'newid').text\r
87                 end\r
88                 \r
89                 def send_edit(ie, id, name, email, password, confirmation, prod_lic_id, permissions)\r
90                 \r
91                         ie.text_field(:id, "account_name").set(name)\r
92                         ie.text_field(:id, "account_email").set(email)\r
93                         ie.text_field(:id, "account_password").set(password)\r
94                         ie.text_field(:id, "account_confirmationpassword").set(confirmation)\r
95                         ie.select_list(:id, "account_ProductLicense_id").select_value(prod_lic_id.to_s)\r
96                         \r
97                         ie.checkboxes.each { |check| check.clear() }\r
98                         \r
99                         permissions.each { |value|\r
100                                 ie.checkbox(:id, 'account_permissions', value.to_s).set\r
101                         }\r
102                         \r
103                         ie.button(:id, 'updatebutton').click\r
105                         # Check for errors\r
106                         \r
107                         fail('There were databind errors') if ie.contains_text('binding error')\r
108                         fail('Unexpected exception') if ie.contains_text('Exception')\r
109                         \r
110                         assert_equal(name, ie.span(:id, 'name').text)\r
111                         assert_equal(email, ie.span(:id, 'email').text)\r
112                         assert_equal(password, ie.span(:id, 'password').text)\r
113                         assert_equal(prod_lic_id, ie.span(:id, 'pl').text) unless prod_lic_id == "0"\r
114                         assert_equal(permissions.sort!, ie.span(:id, 'permissions').text.split(',').sort!)\r
115                 end\r
117         end\r
119 end\r