Added Unit Tests for AccountCreator and Utility

This commit is contained in:
Sreyas Rangaraju 2017-11-27 15:03:36 -05:00
parent 01d93858cb
commit 96082c2aef
2 changed files with 41 additions and 0 deletions

View file

@ -32,6 +32,11 @@ public class AccountCreatorTest {
assertEquals(DeletePolicy.ON_DELETE, result);
}
@Test(expected= IllegalStateException.class)
public void getDefualtDeletePolicy_withSMTP_shouldFail(){
AccountCreator.getDefaultDeletePolicy(Type.SMTP);
}
@Test
public void getDefaultPort_withNoConnectionSecurityAndImap_shouldReturnDefaultPort() {
int result = AccountCreator.getDefaultPort(ConnectionSecurity.NONE, Type.IMAP);

View file

@ -4,6 +4,8 @@ package com.fsck.k9.helper;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class UtilityTest {
@ -41,4 +43,38 @@ public class UtilityTest {
assertEquals("TestTest", result);
}
@Test
public void arrayContains_withObject_ReturnsTrue(){
Object[] container = {10,20,30,40,50,60,71,80,90,91};
Object value = 10;
boolean result = Utility.arrayContains(container, value);
assertTrue(result);
}
@Test
public void arrayContains_withoutObject_ReturnsFalse(){
Object[] container = {10,20,30,40,50,60,71,80,90,91};
Object value = 11;
boolean result = Utility.arrayContains(container, value);
assertFalse(result);
}
@Test
public void arrayContainsAny_withObject_ReturnsTrue(){
Object[] container = {10,20,30,40,50,60,71,80,90,91};
boolean result = Utility.arrayContainsAny(container, 1, 2, 3, 10);
assertTrue(result);
}
@Test
public void arrayContainsAny_withoutObject_ReturnsFalse(){
Object[] container = {10,20,30,40,50,60,71,80,90,91};
boolean result = Utility.arrayContainsAny(container, 1, 2, 3, 4);
assertFalse(result);
}
}