package de.goddchen.android.rxfiredroid.tests;

import android.support.test.runner.AndroidJUnit4;

import junit.framework.Assert;

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

import de.goddchen.android.rxfiredroid.database.RxFireDroidDatabase;

/**
 * Created by goddc on 04.12.2016.
 */

@RunWith(AndroidJUnit4.class)
public class RxFireDroidDatabaseTest {

    @Test
    public void setReadTest() {
        RxFireDroidDatabase.setValue("test-value", true)
                .blockingAwait();
        Assert.assertTrue(RxFireDroidDatabase.getValues("test-value").blockingGet()
                .getValue(Boolean.class));
    }

    @Test
    public void setDeleteTest() {
        RxFireDroidDatabase.setValue("test-value", true)
                .blockingAwait();
        RxFireDroidDatabase.deleteValues("test-value").blockingAwait();
        Assert.assertFalse(RxFireDroidDatabase.getValues("test-value").blockingGet().exists());
    }
}

@@ -92,16 +92,72 @@
 Unit4;%0A%0A
+import com.google.firebase.database.DatabaseReference;%0A%0A
 import j
@@ -179,16 +179,16 @@
 Assert;%0A
-
 %0Aimport 
@@ -305,16 +305,56 @@
 atabase;
+%0Aimport io.reactivex.functions.Function;
 %0A%0A/**%0A *
@@ -927,32 +927,32 @@
 lockingAwait();%0A
-
         Assert.a
@@ -1036,11 +1036,468 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void pathFormatTest() %7B%0A        RxFireDroidDatabase.getRef(%22test/%25s%22, %22arg%22)%0A                .map(new Function%3CDatabaseReference, String%3E() %7B%0A                    @Override%0A                    public String apply(DatabaseReference databaseReference) throws Exception %7B%0A                        return databaseReference.getKey();%0A                    %7D%0A                %7D)%0A                .test()%0A                .assertValue(%22arg%22);%0A    %7D
 %0A%7D%0A

add a test for path format arguments