Files
oops/src/test/java/oving5/twitter/FollowersCountComparatorTest.java
Andreas Omholt Olsen 55c36a603a Add oving 5
2026-02-09 15:28:09 +01:00

36 lines
1.0 KiB
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 FollowersCountComparatorTest {
private TwitterAccount aaron;
private TwitterAccount ben;
private TwitterAccount charlie;
private FollowersCountComparator comparator;
@BeforeEach
public void SetUp() {
aaron = new TwitterAccount("Aaron");
ben = new TwitterAccount("Ben");
charlie = new TwitterAccount("Charlie");
comparator = new FollowersCountComparator();
}
@Test
@DisplayName("Check that the comparison is based on followers")
public void testCompare() {
aaron.follow(ben);
ben.follow(aaron);
assertEquals(0, comparator.compare(aaron, ben), "Aaron and Ben should be equal");
charlie.follow(ben);
assertTrue(comparator.compare(aaron, ben) > 0, "Aaron should come after Ben");
assertTrue(comparator.compare(ben, aaron) < 0, "Ben should come before Aaron");
}
}