package housing.test;

import housing.roles.HousingLandlordRole;
import housing.roles.HousingRenterRole;
import housing.test.mock.MockLandlord;
import housing.test.mock.MockRenter;
import junit.framework.TestCase;
import base.PersonAgent;
import base.interfaces.Person;
import base.interfaces.Role;

/**
 * 
 * This class is a JUnit test class to unit test the Landlord's interaction with
 * renters.
 * 
 * @author Maggi Yang
 */

public class RenterTest extends TestCase {
	// these are instantiated for each test separately via the setUp() method.
	
	Person mPerson;
	HousingRenterRole mHousingRenter;
	MockLandlord mHousingLandlord;


	/**
	 * This method is run before each test. You can use it to instantiate the
	 * class variables for your agent and mocks, etc.
	 */

	public void setUp() throws Exception {
		super.setUp();
		
		//Renter 
		mPerson = new PersonAgent();
		mHousingRenter = new HousingRenterRole(); 
		mPerson.addRole((Role) mHousingRenter, true); 
	
		//Mock Interfaces 
		mHousingLandlord = new MockLandlord("Mocklandlord"); 
		mHousingRenter.setLandlord(mHousingLandlord);
	}
	
	public void testNormativeScenario1()
	{
		/**
		 * Tests that the renter apply and successfully obtains housing from landlord (accepted)
		 */
		
		//Preconditions 
		assertTrue("HousingLandlord has an empty log", mHousingLandlord.log.size() == 0); 
		assertEquals("HousingRenter has no bills", mHousingRenter.mBills.size(), 0); 
		
		//HousingLandlord accepts housing application from HousingRenter 
		//mHousingRenter.msgApplicationAccepted(newHouse);
//		
//		//HousingRenter1 messages HousingLandlord to apply for housing
//		mHousingLandlord.msgIWouldLikeToLiveHere(mHousingRenter1, 500.00, 1);
//		
//		//Check 1
//		assertTrue("HousingLandlord has one renter", mHousingLandlord.mRenterList.size() == 1); 
//		assertTrue("PAEA: return true and does action", mHousingLandlord.pickAndExecuteAnAction());
//		assertTrue("HousingRenter1 should have received acceptance message", mHousingRenter1.log.containsString("Received msgApplicationAccepted"));
//		assertTrue("PAEA: return false", !mHousingLandlord.pickAndExecuteAnAction());
//		
//		//HousingRenter2 messages HousingLandlord to apply for housing
//		mHousingLandlord.msgIWouldLikeToLiveHere(mHousingRenter2, 200.00, 2);
//		
//		//Check 2
//		assertTrue("HousingLandlord has two renters", mHousingLandlord.mRenterList.size() == 2); 
//		assertTrue("PAEA: return true and does action", mHousingLandlord.pickAndExecuteAnAction());
//		assertTrue("HousingRenter2 should have received acceptance message", mHousingRenter2.log.containsString("Received msgApplicationAccepted"));
//		assertTrue("HousingRenter1 should not have received any additional messages", mHousingRenter1.log.size() == 1); 
//		assertTrue("PAEA: return false", !mHousingLandlord.pickAndExecuteAnAction());
//		
//		//HousingRenter3 messages HousingLandlord to apply for housing
//		mHousingLandlord.msgIWouldLikeToLiveHere(mHousingRenter3, 300.00, 3);		
//		
//		//Check 3
//		assertTrue("HousingLandlord has three renters", mHousingLandlord.mRenterList.size() == 3); 
//		assertTrue("PAEA: return true and does action", mHousingLandlord.pickAndExecuteAnAction());
//		assertTrue("HousingRenter3 should have been declined housing", mHousingRenter3.log.containsString("Received msgApplicationDenied"));
//		assertTrue("HousingRenter1 should not have received any additional messages", mHousingRenter1.log.size() == 1); 
//		assertTrue("HousingRenter2 should not have received any additional messages", mHousingRenter2.log.size() == 1); 
//		assertTrue("HousingLandlord should remove HousingRenter3 from RenterList", mHousingLandlord.mRenterList.size() == 2); 
//		assertTrue("PAEA: return false", !mHousingLandlord.pickAndExecuteAnAction());
//	
	}
	

}

@@ -16,16 +16,38 @@
 .test;%0A%0A
+import housing.House;%0A
 import h
@@ -76,24 +76,24 @@
 ndlordRole;%0A
-
 import housi
@@ -652,16 +652,32 @@
 ndlord;%0A
+%09House mHouse; %0A
 %0A%0A%09/**%0A%09
@@ -1131,16 +1131,69 @@
 dlord);%0A
+%09%09%0A%09%09//Houses%0A%09%09mHouse = new House(10, 10, 300.00); %0A
 %09%7D%0A%09%0A%09pu
@@ -1593,18 +1593,16 @@
 nter %0A%09%09
-//
 mHousing
@@ -1631,19 +1631,17 @@
 ccepted(
-new
+m
 House);%0A

create house for testing