made 3 test cases for each class

This commit is contained in:
Batuhan Berk Başoğlu 2018-11-01 23:17:34 -04:00
parent ac00abfa53
commit e9ee14542c
8 changed files with 93 additions and 12 deletions

View file

@ -69,8 +69,6 @@ public abstract class UserType {
} }
public boolean equals(UserType other){ public boolean equals(UserType other){
if(this.username.equals(other.username)&&this.password.equals(other.password)&& if(this.username.equals(other.username)&&this.password.equals(other.password)&&
this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){ this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){

View file

@ -0,0 +1,23 @@
package com.uottawa.olympus.olympusservices;
import org.junit.Test;
import static org.junit.Assert.*;
public class AdminTest {
@Test
public void testAdmin() {
Admin admin = new Admin();
String username = admin.getUsername();
String password = admin.getPassword();
String firstname = admin.getFirstname();
String lastname = admin.getLastname();
String role = admin.getRole();
assertEquals("Admin", role);
assertEquals("admin", username);
assertEquals("admin", password);
assertEquals("Admin", firstname);
assertEquals("Admin", lastname);
}
}

View file

@ -0,0 +1,27 @@
package com.uottawa.olympus.olympusservices;
import org.junit.Test;
import static org.junit.Assert.*;
public class HomeOwnerTest {
@Test
public void testHomeOwner(){
UserType user = new HomeOwner( "John123", "1234567890", "John", "Doe" );
String role = user.getRole();
assertEquals("HomeOwner", role);
assertEquals("John123", user.getUsername());
assertEquals("1234567890", user.getPassword());
assertEquals("John", user.getFirstname());
assertEquals("Doe", user.getLastname());
user.setUsername( "username" );
user.setPassword( "password" );
user.setFirstname( "firstname" );
user.setLastname( "lastname" );
assertNotEquals("John123", user.getUsername());
assertNotEquals("1234567890", user.getPassword());
assertNotEquals("John", user.getFirstname());
assertNotEquals("Doe", user.getLastname());
}
}

View file

@ -1,5 +0,0 @@
import static org.junit.Assert.*;
public class LogInTest {
}

View file

@ -1,5 +1,14 @@
package com.uottawa.olympus.olympusservices;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class ServiceProviderTest { public class ServiceProviderTest {
@Test
public void addService() {
}
} }

View file

@ -0,0 +1,4 @@
package com.uottawa.olympus.olympusservices;
public class ServiceTest {
}

View file

@ -1,5 +0,0 @@
import static org.junit.Assert.*;
public class SignUpTest {
}

View file

@ -0,0 +1,30 @@
package com.uottawa.olympus.olympusservices;
import android.view.View;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.*;
public class UserTypeTest {
@Test
public void userTypeComparaison() {
UserType user = new HomeOwner("John123", "1234567890", "John", "Doe");
UserType admin = new Admin();
UserType serviceprovider = new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe");
boolean userservice = user.equals(serviceprovider);
boolean useradmin = user.equals(admin);
boolean serviceadmin = serviceprovider.equals(admin);
assertNotEquals( true, useradmin );
assertNotEquals( true, serviceadmin );
assertNotEquals( true, userservice );
user.setFirstname(serviceprovider.getFirstname());
user.setUsername(serviceprovider.getUsername());
userservice = user.equals(serviceprovider);
assertEquals( true, userservice );
}
}