package com.mgaetan89.showsrage.activity;

import com.mgaetan89.showsrage.Constants;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.Collection;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(Parameterized.class)
public class BaseActivity_ShouldCheckForUpdateTest {
	@Parameterized.Parameter(1)
	public long lastCheckTime;

	@Parameterized.Parameter(0)
	public boolean manualCheck;

	@Parameterized.Parameter(2)
	public boolean result;

	@Test
	public void shouldCheckForUpdate() {
		assertThat(BaseActivity.shouldCheckForUpdate(this.manualCheck, this.lastCheckTime)).isEqualTo(this.result);
	}

	@Parameterized.Parameters
	public static Collection<Object[]> data() {
		final long offset = 5000L;

		return Arrays.asList(new Object[][]{
				// Automatic check
				{false, System.currentTimeMillis() - Constants.Preferences.Defaults.VERSION_CHECK_INTERVAL - offset, true},
				{false, System.currentTimeMillis() - Constants.Preferences.Defaults.VERSION_CHECK_INTERVAL, true},
				{false, System.currentTimeMillis() - Constants.Preferences.Defaults.VERSION_CHECK_INTERVAL + offset, false},
				{false, System.currentTimeMillis() - offset, false},
				{false, System.currentTimeMillis(), false},
				{false, System.currentTimeMillis() + offset, false},

				// Manual check
				{true, System.currentTimeMillis() - Constants.Preferences.Defaults.VERSION_CHECK_INTERVAL - offset, true},
				{true, System.currentTimeMillis() - Constants.Preferences.Defaults.VERSION_CHECK_INTERVAL, true},
				{true, System.currentTimeMillis() - Constants.Preferences.Defaults.VERSION_CHECK_INTERVAL + offset, true},
				{true, System.currentTimeMillis() - offset, true},
				{true, System.currentTimeMillis(), true},
				{true, System.currentTimeMillis() + offset, true},
		});
	}
}

@@ -1356,16 +1356,38 @@
  false%7D,
+%0A%09%09%09%09%7Bfalse, 0, true%7D,
 %0A%0A%09%09%09%09//
@@ -1880,16 +1880,37 @@
  true%7D,%0A
+%09%09%09%09%7Btrue, 0, true%7D,%0A
 %09%09%7D);%0A%09%7D

Update test