Added DictionaryAdapter.build.
[castle.git] / MonoRail / WatirTestCases / ARSupport / productlicense.rb
blobaa753ce3f05a5e6b00c87e2f04eb6c0c8371692e
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 ProductLicense\r
19         class << self\r
21                 include Test::Unit::Assertions\r
23                 def create(ie, created, expires)\r
25                         ie.goto("#{$base_url}/ProductLicense/new.castle")\r
27                         ie.text_field(:id, "pl_created").set(created)\r
28                         ie.text_field(:id, "pl_Expires").set(expires)\r
29                         \r
30                         ie.button(:id, 'insertbutton').click\r
32                         # Check for errors\r
33                         \r
34                         fail('There were databind errors') if ie.contains_text('binding error')\r
35                         fail('Unexpected exception') if ie.contains_text('Exception')\r
36                         \r
37                         assert_equal(created, ie.span(:id, 'created').text, 'Insert: created was not set')\r
38                         assert_equal(expires, ie.span(:id, 'expires').text, 'Insert: expires was not set')\r
40                         # returns new id\r
41                         \r
42                         ie.span(:id, 'newid').text\r
43                         \r
44                 end\r
45                 \r
46                 def create_with_accounts(ie, created, expires, *accounts)\r
48                         ie.goto("#{$base_url}/ProductLicense/newwithaccounts.castle")\r
50                         ie.text_field(:id, "pl_created").set(created)\r
51                         ie.text_field(:id, "pl_Expires").set(expires)\r
52                         \r
53                         accounts.each { |value|\r
54                                 ie.checkbox(:id, 'pl_accounts', value.to_s).set\r
55                         }\r
56                         \r
57                         ie.button(:id, 'insertbutton').click\r
59                         # Check for errors\r
60                         \r
61                         fail('There were databind errors') if ie.contains_text('binding error')\r
62                         fail('Unexpected exception') if ie.contains_text('Exception')\r
63                         \r
64                         assert_equal(created, ie.span(:id, 'created').text, 'Insert: created was not set')\r
65                         assert_equal(expires, ie.span(:id, 'expires').text, 'Insert: expires was not set')\r
66                         assert_equal(accounts.sort!, ie.span(:id, 'accounts').text.split(',').sort!)\r
68                         # returns new id\r
69                         \r
70                         ie.span(:id, 'newid').text\r
71                         \r
72                 end\r
73                 \r
74                 def edit(ie, id, created, expires)\r
76                         ie.goto("#{$base_url}/ProductLicense/edit.castle?id=#{id}")\r
78                         ie.text_field(:id, "pl_created").set(created)\r
79                         ie.text_field(:id, "pl_Expires").set(expires)\r
80                         \r
81                         ie.button(:id, 'updatebutton').click\r
83                         # Check for errors\r
84                         \r
85                         fail('There were databind errors') if ie.contains_text('binding error')\r
86                         fail('Unexpected exception') if ie.contains_text('Exception')\r
87                         \r
88                         assert_equal(created, ie.span(:id, 'created').text, 'Insert: created was not set')\r
89                         assert_equal(expires, ie.span(:id, 'expires').text, 'Insert: expires was not set')\r
90                         \r
91                 end\r
92                 \r
93                 def delete(ie, id)\r
95                         ie.goto("#{$base_url}/ProductLicense/removeconfirm.castle?id=#{id}")\r
97                         fail('Looks like removeConfirm.castle didnt load instance') unless ie.contains_text("Confirm removal of #{id}?")\r
98                         \r
99                         ie.button(:id, 'button').click\r
101                         fail('Error removing instance') unless ie.contains_text('Removed')\r
102                         fail('Unexpected exception') if ie.contains_text('Exception')\r
103                         \r
104                 end\r
106         end\r