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,38 @@
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 TweetsCountComparatorTest {
private TwitterAccount mostTweet;
private TwitterAccount lessTweet1;
private TwitterAccount lessTweet2;
private TweetsCountComparator comparator;
@BeforeEach
public void SetUp() {
mostTweet = new TwitterAccount("Aaron");
lessTweet1 = new TwitterAccount("Ben");
lessTweet2 = new TwitterAccount("Charlie");
comparator = new TweetsCountComparator();
}
@Test
@DisplayName("Check comparison based on tweets")
public void testCompare() {
mostTweet.tweet("Tweet");
mostTweet.tweet("Tweet");
lessTweet1.tweet("Tweet");
lessTweet2.tweet("Tweet");
assertTrue(comparator.compare(mostTweet, lessTweet1) < 0,
"The account with the most tweets should come first");
assertTrue(comparator.compare(lessTweet1, mostTweet) > 0,
"The account with the fewest tweets should come last");
assertEquals(0, comparator.compare(lessTweet1, lessTweet2),
"Two accounts with the same number of tweets should be equal");
}
}