@Test public void testGetLastName() { EasyMock.expect(memberMock.getLastName()).andReturn(member.getLastName()); EasyMock.replay(memberMock); System.out.println( "\nThis test demonstrates sending of lastName variable's value from origin to destination."); boolean b; String s = memberMock.getLastName(); if (member.getLastName().equals(s)) { System.out.println("Last Name " + s + " match origin string value. -- PASS"); b = true; } else { System.out.println("Last Name " + s + " does not match origin string value. -- FAIL"); b = false; } assertTrue(b); }
@Test public void memberConstructorValid() { EasyMock.expect(memberMock.getFirstName()).andReturn(member.getFirstName()); EasyMock.expect(memberMock.getLastName()).andReturn(member.getLastName()); EasyMock.expect(memberMock.getContactPhone()).andReturn(member.getContactPhone()); EasyMock.expect(memberMock.getEmailAddress()).andReturn(member.getEmailAddress()); EasyMock.expect(memberMock.getID()).andReturn(member.getID()); EasyMock.replay(memberMock); System.out.println( "\nThis test will demonstrate construction of a member class in a valid manner" + "\nThis test simulates the creation of a new Member class by storing its visible names, " + "\nthen comparing them to the variables that carried the names that are used in storing " + "\nto the inputs for the member class construction."); String s = memberMock.getFirstName(); assertEquals(firstName, s); if (firstName.equals(s)) System.out.println("First Name: " + firstName + ", mock result: " + s + " -- PASS"); else System.out.println("First Name: " + firstName + ", mock result: " + s + " -- FAIL"); s = memberMock.getLastName(); assertEquals(lastName, s); if (lastName.equals(s)) System.out.println("Last Name: " + lastName + ", mock result: " + s + " -- PASS"); else System.out.println("Last Name: " + lastName + ", mock result: " + s + " -- FAIL"); s = memberMock.getContactPhone(); assertEquals(contactPhone, s); if (contactPhone.equals(s)) System.out.println("Contact Phone: " + contactPhone + ", mock result: " + s + " -- PASS"); else System.out.println("Contact Phone: " + contactPhone + ", mock result: " + s + " -- FAIL"); s = memberMock.getEmailAddress(); assertEquals(emailAddress, s); if (emailAddress.equals(s)) System.out.println("Email Address: " + emailAddress + ", mock result: " + s + " -- PASS"); else System.out.println("Email Address: " + emailAddress + ", mock result: " + s + " -- FAIL"); int i = memberMock.getID(); assertEquals(id, i); if (id == i) System.out.println("Last Name: " + id + ", mock result: " + i + " -- PASS"); else System.out.println("Last Name: " + id + ", mock result: " + i + " -- FAIL"); }