Add oving 5

This commit is contained in:
Andreas Omholt Olsen
2026-02-09 15:28:09 +01:00
parent 6193e26ba1
commit 55c36a603a
33 changed files with 1586 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
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");
}
}