note
	description: "Summary description for {TEST_REGISTRATION2}."
	author: ""
	date: "$Date$"
	revision: "$Revision$"

class 
	TEST_REGISTRATION2

inherit
	ES_TEST
		redefine
			setup
		end

create 
	make

feature {NONE} -- Initialization

	make
			-- Run application.
		do
			setup
			add_boolean_case (agent t0)
			add_boolean_case (agent t1)
			add_violation_case_with_tag ("max_course_load", agent t2)
			add_violation_case_with_tag ("no_conflicting_registrations", agent t3)
		end
	
feature -- common setup

	c1: COURSE

	c2: COURSE

	c3: COURSE

	c4: COURSE

	c5: COURSE

	s1: STUDENT

	s2: STUDENT

	s3: STUDENT

	reg: REGISTRATION

	setup
			-- Will be executed at the beginning of "run" in a test case.
		do
			create s1.make ("s1")
			create s2.make ("s2")
			create s3.make ("s3")
			create c1.make ("EECS3311", 1, "16:00", "17:30")
			create c2.make ("EECS3342", 2, "11:30", "13:00")
			create c3.make ("EECS3191", 1, "15:00", "16:30")
			create c4.make ("EECS3221", 1, "19:00", "22:00")
			create c5.make ("EECS3401", 3, "19:00", "22:00")
			create reg
		end
	
feature -- tests

	t0: BOOLEAN
		do
			comment ("t0: test sessions conflict")
			Result := not reg.conflict (create {COURSE}.make ("C1", 1, "19:00", "22:00"), create {COURSE}.make ("C2", 2, "19:00", "22:00"))
			check
					Result
			end
			Result := not reg.conflict (create {COURSE}.make ("C1", 2, "15:59", "18:59"), create {COURSE}.make ("C2", 2, "19:00", "22:00"))
			check
					Result
			end
			Result := reg.conflict (create {COURSE}.make ("C1", 2, "16:00", "19:00"), create {COURSE}.make ("C2", 2, "19:00", "22:00"))
			check
					Result
			end
			Result := reg.conflict (create {COURSE}.make ("C1", 2, "19:00", "22:00"), create {COURSE}.make ("C2", 2, "16:00", "19:00"))
			Result := reg.conflict (create {COURSE}.make ("C1", 2, "19:00", "20:00"), create {COURSE}.make ("C2", 2, "19:00", "22:00"))
			check
					Result
			end
		end

	t1: BOOLEAN
		local
			set1, set12, set23, set3: SET [COURSE]
		do
			comment ("t1: basic tests on registrar")
			reg.extend (s1, c1)
			create set1.make_from_array (<<c1>>)
			Result := # reg.registrations = 1 and then reg.registrations.image (s1) ~ set1
			check
					Result
			end
			reg.extend (s1, c2)
			create set12.make_from_array (<<c1, c2>>)
			Result := # reg.registrations = 2 and then reg.registrations.image (s1) ~ set12
			check
					Result
			end
			reg.extend (s2, c3)
			create set3.make_from_array (<<c3>>)
			Result := # reg.registrations = 3 and then reg.registrations.image (s2) ~ set3
			check
					Result
			end
			reg.extend (s2, c2)
			create set23.make_from_array (<<c3, c2>>)
			Result := # reg.registrations = 4 and then reg.registrations.image (s2) ~ set23
			check
					Result
			end
		end

	t2
		do
			comment ("t2: test max course load")
			reg.extend (s1, c1)
			reg.extend (s1, c2)
			reg.extend (s1, c4)
			reg.extend (s1, c5)
		end

	t3
		do
			comment ("t3: test conflicting courses")
			reg.extend (s1, c1)
			reg.extend (s1, c3)
		end
	
end -- class TEST_REGISTRATION2

Generated by ISE EiffelStudio