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
18 require 'test/unit/ui/console/testrunner'
\r
22 require 'accountpermission'
\r
23 require 'productlicense'
\r
26 require 'personuser'
\r
28 require 'conditiontype'
\r
31 # Test cases for MonoRail ActiveRecord support
\r
33 ## -- Account Permission --
\r
35 ## Creates three Account Permissions
\r
37 class AccountPermissionTestCase < Test::Unit::TestCase
\r
40 id = AccountPermission.create($ie, 'account permission 1')
\r
42 AccountPermission.edit($ie, id, 'other name')
\r
44 #AccountPermission.edit($ie, id, '')
\r
46 AccountPermission.edit($ie, id, 'new name')
\r
48 AccountPermission.delete($ie, id)
\r
53 class UserTestCase < Test::Unit::TestCase
\r
56 user = User.create($ie, 'User name 1')
\r
58 user = User.create($ie, 'User name 2')
\r
63 class ConditionTypeTestCase < Test::Unit::TestCase
\r
66 ConditionType.create($ie, 'Simple 1')
\r
68 ConditionType.create($ie, 'Simple 2')
\r
73 class ConditionTestCase < Test::Unit::TestCase
\r
75 def test_insert_update()
\r
76 t1 = ConditionType.create($ie, 'Type 1')
\r
77 t2 = ConditionType.create($ie, 'Type 2')
\r
79 # Uses the standard approach to send multiple values (indexed node)
\r
80 id = Condition.create($ie, 'name', t1, "1","2","3","4")
\r
82 Condition.edit($ie, id, 'new name', t2, "1","2","3","4")
\r
87 class ProductLicenseTestCase < Test::Unit::TestCase
\r
90 id = ProductLicense.create($ie, '1/2/2006', '2/2/2007')
\r
92 ProductLicense.edit($ie, id, '1/3/2006', '2/4/2007')
\r
94 ProductLicense.delete($ie, id)
\r
99 class AccountTestCase < Test::Unit::TestCase
\r
102 ap1 = AccountPermission.create($ie, 'account permission 1')
\r
103 ap2 = AccountPermission.create($ie, 'account permission 2')
\r
104 pl1 = ProductLicense.create($ie, '1/2/2006', '2/2/2007')
\r
106 # Uses the standard approach to send multiple values (indexed node)
\r
107 id = Account.create($ie, 'account name', 'hammett@gmail.com', '123', '123', pl1, ap1, ap2)
\r
109 Account.edit($ie, id, 'new account name', 'hammett@apache.org', 'xpto', 'xpto', pl1, ap2)
\r
111 Account.delete($ie, id)
\r
113 # Uses a different approach to send multiple values (leafnode with array)
\r
114 id = Account.create2($ie, 'account name', 'hammett@gmail.com', '123', '123', pl1, ap1, ap2)
\r
116 Account.delete($ie, id)
\r
121 class CategoryTestCase < Test::Unit::TestCase
\r
124 id = Category.create($ie, 'name')
\r
126 Category.edit($ie, id, 'new name')
\r
128 Category.delete($ie, id)
\r
133 class ProductLicenseOneToManyTestCase < Test::Unit::TestCase
\r
137 # Uses the standard approach to send multiple values (indexed node)
\r
138 id1 = Account.create($ie, 'account name', 'hammett@gmail.com', '123', '123', '0')
\r
139 id2 = Account.create($ie, 'account name', 'hammett@gmail.com', '123', '123', '0')
\r
141 pl1 = ProductLicense.create_with_accounts($ie, '1/2/2006', '2/2/2007', id1, id2)
\r
143 Account.delete($ie, id1)
\r
144 Account.delete($ie, id2)
\r
146 ProductLicense.delete($ie, pl1)
\r
152 class PersonUserJoinedSubClassWithAbstractGenericPersonBaseTestCase < Test::Unit::TestCase
\r
155 id1 = PersonUser.create($ie, 'MyFirstName1', 'MyMiddleName1', 'MyLastName1', 'MyUserName1', 'MyPassword1')
\r
156 id2 = PersonUser.create($ie, 'MyFirstName2', 'MyMiddleName2', 'MyLastName2', 'MyUserName2', 'MyPassword2')
\r
158 PersonUser.delete($ie, id1)
\r
159 PersonUser.delete($ie, id2)
\r
166 suite = Test::Unit::TestSuite.new
\r
167 suite << UserTestCase.suite
\r
168 suite << ConditionTypeTestCase.suite
\r
169 suite << ConditionTestCase.suite
\r
170 suite << AccountPermissionTestCase.suite
\r
171 suite << ProductLicenseTestCase.suite
\r
172 suite << AccountTestCase.suite
\r
173 suite << CategoryTestCase.suite
\r
174 suite << ProductLicenseOneToManyTestCase.suite
\r
175 suite << PersonUserJoinedSubClassWithAbstractGenericPersonBaseTestCase.suite
\r
180 $base_url = "http://localhost:1556"
\r
184 Test::Unit::UI::Console::TestRunner.run(CastleTests)
\r