forked from framework-one/fw1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModelServiceTest.cfc
31 lines (27 loc) · 1.27 KB
/
ModelServiceTest.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
component extends="mxunit.framework.TestCase" {
function setup() {
application.userServiceCount = 0;
variables.factory = new framework.ioc( "/tests/model, /tests/services", { transients = [ "fish" ] } );
}
function shouldHaveUserFishAndUserService() {
assertTrue( variables.factory.containsBean( "userFish" ) );
assertTrue( variables.factory.containsBean( "userService" ) );
assertFalse( variables.factory.containsBean( "user" ) );
var user1 = variables.factory.getBean( "userFish" );
var user2 = variables.factory.getBean( "userFish" );
assertNotSame( user1, user2 );
}
function shouldInjectUserServiceIntoProduct() {
assertEquals( 0, application.userServiceCount );
var svc1 = variables.factory.getBean( "userService" );
assertEquals( 1, application.userServiceCount );
var svc2 = variables.factory.getBean( "userService" );
assertEquals( 1, application.userServiceCount );
var svc3 = variables.factory.getBean( "product" );
assertSame( svc1, svc2 );
assertEquals( 1, svc1.getId() );
assertEquals( 1, svc2.getId() );
assertEquals( 1, svc3.getUserService().getId() );
assertSame( svc1, svc3.getUserService() );
}
}