33 lines
1009 B
Java
33 lines
1009 B
Java
package oving5.twitter;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.DisplayName;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
public class UserNameComparatorTest {
|
|
|
|
private TwitterAccount aaron1;
|
|
private TwitterAccount aaron2;
|
|
private TwitterAccount ben;
|
|
private UserNameComparator comparator;
|
|
|
|
@BeforeEach
|
|
public void setUp() {
|
|
aaron1 = new TwitterAccount("Aaron");
|
|
aaron2 = new TwitterAccount("Aaron");
|
|
ben = new TwitterAccount("Ben");
|
|
comparator = new UserNameComparator();
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("Check comparison based on username")
|
|
public void testCompare() {
|
|
assertTrue(comparator.compare(aaron1, ben) < 0, "Aaron should be sorted before Ben");
|
|
assertTrue(comparator.compare(ben, aaron1) > 0, "Ben should be sorted after Aaron");
|
|
assertEquals(comparator.compare(aaron1, aaron2), 0,
|
|
"Two people with the same name should be equal");
|
|
}
|
|
}
|