source: trunk/test/unit/dbnp/studycapturing/EventTests.groovy @ 536

Last change on this file since 536 was 536, checked in by roberth, 11 years ago

Samples are now shown in the study overview page. Also some tests are added and the bootstrap is updated to show some sample fields with a template

  • Property svn:keywords set to Date Author Rev
File size: 1.7 KB
Line 
1package dbnp.studycapturing
2
3import grails.test.*
4
5class EventTests extends GrailsUnitTestCase {
6    protected void setUp() {
7        super.setUp()
8    }
9
10    protected void tearDown() {
11        super.tearDown()
12    }
13
14    void testBelongsToGroup() {
15        def events = [];
16        10.times {
17            events[ it ] = new Event(
18                id: it,
19                startTime: 3600,
20                endTime: 3800
21            )
22            println( 'Created event ' + it );
23        }
24        def evGroup1 = new EventGroup(
25            name: 'group1',
26            events: events[0..4]
27        )
28        def evGroup2 = new EventGroup(
29            name: 'group2',
30            events: events[3..6]
31        )
32
33        Set<EventGroup> set1 = new HashSet<EventGroup>();
34        Set<EventGroup> set2 = new HashSet<EventGroup>();
35        Set<EventGroup> setBoth = new HashSet<EventGroup>();
36        Set<EventGroup> setEmpty = new HashSet<EventGroup>();
37        set1.add( evGroup1 );
38        set2.add( evGroup2 );
39        setBoth.add( evGroup1 );
40        setBoth.add( evGroup2 );
41
42        assert events[0].belongsToGroup( set1 );
43        assert events[3].belongsToGroup( set1 );
44        assert !events[6].belongsToGroup( set1 );
45
46        assert events[3].belongsToGroup( set2 );
47        assert events[6].belongsToGroup( set2 );
48
49        assert !events[0].belongsToGroup( setEmpty );
50        assert !events[8].belongsToGroup( setEmpty );
51
52        assert events[0].belongsToGroup( setBoth );
53        assert events[3].belongsToGroup( setBoth );
54        assert events[6].belongsToGroup( setBoth );
55
56        assert !events[7].belongsToGroup( setBoth );
57
58    }
59}
Note: See TracBrowser for help on using the repository browser.