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");
	}
}
