diff --git a/app/build.gradle b/app/build.gradle
index b6fb2d8..3f745f2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -27,12 +27,15 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
+ //androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.1', {
+ exclude group: 'com.android.support', module: 'support-annotations'
})
- compile 'com.android.support:appcompat-v7:26.+'
+ compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
+ testCompile 'org.mockito:mockito-core:1.10.19'
+ //testCompile 'com.android.support.test:runner:1.0.1'
compile "android.arch.lifecycle:runtime:1.0.0-alpha9-1"
compile "android.arch.lifecycle:extensions:1.0.0-alpha9-1"
diff --git a/app/src/androidTest/java/carbon/crypto/com/carbon/Assertions/RecyclerViewItemsCountAssertion.java b/app/src/androidTest/java/carbon/crypto/com/carbon/Assertions/RecyclerViewItemsCountAssertion.java
new file mode 100644
index 0000000..7edec28
--- /dev/null
+++ b/app/src/androidTest/java/carbon/crypto/com/carbon/Assertions/RecyclerViewItemsCountAssertion.java
@@ -0,0 +1,32 @@
+package carbon.crypto.com.carbon.Assertions;
+
+import android.support.test.espresso.NoMatchingViewException;
+import android.support.test.espresso.ViewAssertion;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Created by Henry Varona on 19/9/2017.
+ */
+
+public class RecyclerViewItemsCountAssertion implements ViewAssertion {
+ private final int expectedCount;
+
+ public RecyclerViewItemsCountAssertion(int expectedCount) {
+ this.expectedCount = expectedCount;
+ }
+
+ @Override
+ public void check(View view, NoMatchingViewException noViewFoundException) {
+ if (noViewFoundException != null) {
+ throw noViewFoundException;
+ }
+
+ RecyclerView recyclerView = (RecyclerView) view;
+ RecyclerView.Adapter adapter = recyclerView.getAdapter();
+ assertThat(adapter.getItemCount(), is(expectedCount));
+ }
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/carbon/crypto/com/carbon/ExampleInstrumentedTest.java b/app/src/androidTest/java/carbon/crypto/com/carbon/ExampleInstrumentedTest.java
deleted file mode 100644
index 906c281..0000000
--- a/app/src/androidTest/java/carbon/crypto/com/carbon/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package carbon.crypto.com.carbon;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("carbon.crypto.com.carbon", appContext.getPackageName());
- }
-}
diff --git a/app/src/androidTest/java/carbon/crypto/com/carbon/TransactionListTest.java b/app/src/androidTest/java/carbon/crypto/com/carbon/TransactionListTest.java
new file mode 100644
index 0000000..2884cbc
--- /dev/null
+++ b/app/src/androidTest/java/carbon/crypto/com/carbon/TransactionListTest.java
@@ -0,0 +1,74 @@
+package carbon.crypto.com.carbon;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import carbon.crypto.com.carbon.Assertions.RecyclerViewItemsCountAssertion;
+import cy.agorise.crystalwallet.IntroActivity;
+import cy.agorise.crystalwallet.R;
+import cy.agorise.crystalwallet.dao.CrystalDatabase;
+import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+
+/**
+ * Created by Henry Varona on 19/9/2017.
+ */
+@RunWith(AndroidJUnit4.class)
+public class TransactionListTest {
+ CrystalDatabase db;
+
+ @Before
+ public void addingTransactions(){
+ Calendar cal = Calendar.getInstance();
+
+ this.db = CrystalDatabase.getAppDatabase(InstrumentationRegistry.getTargetContext());
+ cal.set(2017,01,01,01,01,01);
+ CryptoCoinTransaction newTransaction = new CryptoCoinTransaction();
+ newTransaction.setAmount(1);
+ newTransaction.setFrom("friend1");
+ newTransaction.setTo("me1");
+ newTransaction.setDate(cal.getTime());
+ db.transactionDao().insertTransaction(newTransaction);
+
+ cal.set(2017,02,02,02,02,02);
+ newTransaction = new CryptoCoinTransaction();
+ newTransaction.setAmount(2);
+ newTransaction.setFrom("friend2");
+ newTransaction.setTo("me2");
+ newTransaction.setDate(cal.getTime());
+ db.transactionDao().insertTransaction(newTransaction);
+
+ cal.set(2017,03,03,03,03,03);
+ newTransaction = new CryptoCoinTransaction();
+ newTransaction.setAmount(3);
+ newTransaction.setFrom("friend3");
+ newTransaction.setTo("me3");
+ newTransaction.setDate(cal.getTime());
+ db.transactionDao().insertTransaction(newTransaction);
+ }
+
+ @Rule
+ public ActivityTestRule activityTestRule = new ActivityTestRule(IntroActivity.class);
+
+ @Test
+ public void numberOfTransactionsInList(){
+ onView(withId(R.id.transactionListView)).check(new RecyclerViewItemsCountAssertion(3));
+ }
+
+ @After
+ public void deleteTransactions(){
+ this.db.transactionDao().deleteAllTransactions();
+ }
+}
diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java
index c29c0eb..281bc3e 100644
--- a/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java
+++ b/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java
@@ -25,4 +25,7 @@ public interface TransactionDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
public void insertTransaction(CryptoCoinTransaction... transactions);
+
+ @Query("DELETE FROM crypto_coin_transaction")
+ public void deleteAllTransactions();
}