forked from PaystackHQ/paystack-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jacoco and Test updates (PaystackHQ#131)
* Jacoco and Test updates - Added Jacoco agents properties file to init jacoco when running the example project - Moved the Unit Tests that were in the example project to the SDK module - Added the Jacoco build script to the SDK module - Removed a filter that does not exist - Updated Jacoco exludes
- Loading branch information
1 parent
28f162f
commit 95de07e
Showing
5 changed files
with
147 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
output=none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package co.paystack.android; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.Calendar; | ||
|
||
import co.paystack.android.model.Card; | ||
|
||
import static org.junit.Assert.assertSame; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Test the card class | ||
*/ | ||
|
||
public class CardTest { | ||
|
||
private static final int YEAR = Calendar.getInstance().get(Calendar.YEAR); | ||
private static final int MONTH = Calendar.getInstance().get(Calendar.MONTH); | ||
|
||
private static final int YEAR_FUTURE = Calendar.getInstance().get(Calendar.YEAR) + 1; | ||
private static final int YEAR_PAST = Calendar.getInstance().get(Calendar.YEAR) - 2; | ||
private static final int MONTH_PAST = (MONTH > Calendar.getInstance().getMinimum(Calendar.MONTH)) ? MONTH - 1 : Calendar.getInstance().getMaximum(Calendar.MONTH); | ||
|
||
|
||
private static final String CVC_3 = "123"; | ||
private static final String CVC_4 = "1234"; | ||
|
||
private static final String MASTER_CARD_NUMBER = "5105105105105100"; | ||
|
||
private static final String DISCOVER_CARD_NUMBER = "6500000000000002"; | ||
|
||
private static final String VISA_CARD_NUMBER = "4111111111111111"; | ||
private static final String VISA_CARD_NUMBER_2 = "4342-5611-1111-1118"; | ||
|
||
private static final String AMEX_CARD_NUMBER = "341111111111111"; | ||
|
||
@Test | ||
public void testExpiredCardMonth() throws Exception { | ||
Card card = new Card.Builder(MASTER_CARD_NUMBER, YEAR, MONTH_PAST, "123").build(); | ||
assertSame(false, card.validExpiryDate()); | ||
} | ||
|
||
@Test | ||
public void testExpiredCardYear() throws Exception { | ||
Card card = new Card.Builder(MASTER_CARD_NUMBER, YEAR_PAST, Calendar.DECEMBER + 1, "123").build(); | ||
assertSame(false, card.validExpiryDate()); | ||
} | ||
|
||
@Test | ||
public void canInitializeCardWithBuilder() throws Exception { | ||
Card card = new Card.Builder(MASTER_CARD_NUMBER, 3, YEAR_FUTURE, "123").build(); | ||
assertTrue(card.isValid()); | ||
} | ||
|
||
@Test | ||
public void testTypeDetectionMasterCard() throws Exception { | ||
Card card = new Card(MASTER_CARD_NUMBER, YEAR, MONTH, CVC_3); | ||
assertSame(Card.CardType.MASTERCARD, card.getType()); | ||
} | ||
|
||
@Test | ||
public void testTypeDetectionAmericanExpress() throws Exception { | ||
Card card = new Card(AMEX_CARD_NUMBER, YEAR, MONTH, CVC_4); | ||
assertSame(Card.CardType.AMERICAN_EXPRESS, card.getType()); | ||
} | ||
|
||
@Test | ||
public void testTypeDetectionVisaCard() throws Exception { | ||
Card card = new Card(VISA_CARD_NUMBER, YEAR, MONTH, CVC_3); | ||
assertSame(Card.CardType.VISA, card.getType()); | ||
} | ||
|
||
//TODO: testTypeDetectionDiscoverCard This test was failing and we need to have look at it. | ||
} |
23 changes: 23 additions & 0 deletions
23
paystack/src/test/java/co/paystack/android/PaystackSdkTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package co.paystack.android; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* PaystackSdk Test Class | ||
* <p/> | ||
* Tests the paystack sdk | ||
*/ | ||
|
||
public class PaystackSdkTest { | ||
|
||
private static final String TEST_PUBLIC_KEY = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANIsL+RHqfkBiKGn/D1y1QnNrMkKzxWP\n" + | ||
"2wkeSokw2OJrCI+d6YGJPrHHx+nmb/Qn885/R01Gw6d7M824qofmCvkCAwEAAQ=="; | ||
|
||
@Test(expected = NullPointerException.class) | ||
public void initPaystackSdkWithNullParamsShouldThrowException() { | ||
PaystackSdk.initialize(null); | ||
} | ||
|
||
//TODO: Look at this SDK Unit Test initPaystackSdkWithPaystackActivityShouldPass | ||
|
||
} |