private void updateIconCvc( @NonNull @Card.CardBrand String brand, boolean hasFocus, @Nullable String cvcText) { if (shouldIconShowBrand(brand, hasFocus, cvcText)) { updateIcon(brand); } else { updateIconForCvcEntry(Card.AMERICAN_EXPRESS.equals(brand)); } }
@Test public void shouldIconShowBrand_whenNotAmexAndCvcStringLengthIsNotThree_isFalse() { assertFalse(shouldIconShowBrand(Card.VISA, true, "")); assertFalse(shouldIconShowBrand(Card.DISCOVER, true, "12")); assertFalse(shouldIconShowBrand(Card.JCB, true, "55")); assertFalse(shouldIconShowBrand(Card.MASTERCARD, true, "9")); assertFalse(shouldIconShowBrand(Card.DINERS_CLUB, true, null)); assertFalse(shouldIconShowBrand(Card.UNKNOWN, true, "12")); }
@Test public void shouldIconShowBrand_whenCvcNotFocused_isAlwaysTrue() { assertTrue(shouldIconShowBrand(Card.AMERICAN_EXPRESS, false, "1234")); assertTrue(shouldIconShowBrand(Card.AMERICAN_EXPRESS, false, "")); assertTrue(shouldIconShowBrand(Card.VISA, false, "333")); assertTrue(shouldIconShowBrand(Card.DINERS_CLUB, false, "12")); assertTrue(shouldIconShowBrand(Card.DISCOVER, false, null)); assertTrue(shouldIconShowBrand(Card.JCB, false, "7")); }
@Test public void shouldIconShowBrand_whenNotAmexAndCvcStringLengthIsThree_isTrue() { assertTrue(shouldIconShowBrand(Card.VISA, true, "999")); assertTrue(shouldIconShowBrand(Card.DISCOVER, true, "123")); assertTrue(shouldIconShowBrand(Card.JCB, true, "555")); assertTrue(shouldIconShowBrand(Card.MASTERCARD, true, "919")); assertTrue(shouldIconShowBrand(Card.DINERS_CLUB, true, "415")); assertTrue(shouldIconShowBrand(Card.UNKNOWN, true, "212")); } }
@Test public void shouldIconShowBrand_whenAmexAndCvCStringLengthNotFour_isFalse() { assertFalse(shouldIconShowBrand(Card.AMERICAN_EXPRESS, true, "")); assertFalse(shouldIconShowBrand(Card.AMERICAN_EXPRESS, true, "1")); assertFalse(shouldIconShowBrand(Card.AMERICAN_EXPRESS, true, "22")); assertFalse(shouldIconShowBrand(Card.AMERICAN_EXPRESS, true, "333")); }
@Test public void shouldIconShowBrand_whenAmexAndCvcStringLengthIsFour_isTrue() { assertTrue(shouldIconShowBrand(Card.AMERICAN_EXPRESS, true, "1234")); }