1 ## Copyright 2004-2007 Castle Project - http://www.castleproject.org/
\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
7 ## http://www.apache.org/licenses/LICENSE-2.0
\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
17 class ProductLicense
\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
30 ie.button(:id, 'insertbutton').click
\r
34 fail('There were databind errors') if ie.contains_text('binding error')
\r
35 fail('Unexpected exception') if ie.contains_text('Exception')
\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
42 ie.span(:id, 'newid').text
\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
53 accounts.each { |value|
\r
54 ie.checkbox(:id, 'pl_accounts', value.to_s).set
\r
57 ie.button(:id, 'insertbutton').click
\r
61 fail('There were databind errors') if ie.contains_text('binding error')
\r
62 fail('Unexpected exception') if ie.contains_text('Exception')
\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
70 ie.span(:id, 'newid').text
\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
81 ie.button(:id, 'updatebutton').click
\r
85 fail('There were databind errors') if ie.contains_text('binding error')
\r
86 fail('Unexpected exception') if ie.contains_text('Exception')
\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
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
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