package uk.ac.ox.oucs.vle;

import java.util.Collections;

public class TestCourseSignupServiceImpl extends TestOnSampleData {
	
	private CourseSignupService service;
	
	public void onSetUp() throws Exception {
		service = (CourseSignupService) getApplicationContext().getBean(CourseSignupService.class.getName());
	}
	
	public void testSignupGood() {
		service.signup(Collections.singleton("comp-1"), "test.user.1@dept.ox.ac.uk", null);
	}
	
	public void testSignupFuture() {
		try{
			// Isn't open yet.
			service.signup(Collections.singleton("comp-5"), "test.user.1@dept.ox.ac.uk", null);
			fail("Should throw exception");
		} catch (IllegalStateException ise) {}
	}
	
	public void testSignupPast() {
		try {
			// Is now closed.
			service.signup(Collections.singleton("comp-6"), "test.user.1@dept.ox.ac.uk", null);
			fail("Should throw exception");
		} catch (IllegalStateException ise) {}
	}
	
	public void testSignupBadUser() {
		try {
			service.signup(Collections.singleton("comp-1"), "nosuchuser@ox.ac.uk", null);
			fail("Should throw exception");
		} catch (IllegalArgumentException iae) {}
	}

	public void testSignupFull() {
		try {
			service.signup(Collections.singleton("comp-8"), "test.user.1@dept.ox.ac.uk", null);
			fail("Should throw exception");
		} catch (IllegalStateException ise) {}
	}
}

@@ -50,16 +50,64 @@
 ections;
+%0Aimport java.util.HashSet;%0Aimport java.util.Set;
 %0A%0Apublic
@@ -476,32 +476,251 @@
 k%22, null);%0A%09%7D%0A%09%0A
+%09public void testSignupGoodSet() %7B%0A%09%09Set%3CString%3E componentIds = new HashSet%3CString%3E();%0A%09%09componentIds.add(%22comp-1%22);%0A%09%09componentIds.add(%22comp-2%22);%0A%09%09service.signup(componentIds, %22test.user.1@dept.ox.ac.uk%22, null);%0A%09%7D%0A%09%0A
 %09public void tes

Test a set of signups.