-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from braille-systems/release/1.1.0
Release/1.1.0
- Loading branch information
Showing
54 changed files
with
1,557 additions
and
249 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
65 changes: 65 additions & 0 deletions
65
...Test/java/com/github/braillesystems/learnbraille/data/repository/ActionsRepositoryTest.kt
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,65 @@ | ||
package com.github.braillesystems.learnbraille.data.repository | ||
|
||
import androidx.room.Room | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.github.braillesystems.learnbraille.data.db.LearnBrailleDatabase | ||
import com.github.braillesystems.learnbraille.data.entities.Action | ||
import com.github.braillesystems.learnbraille.data.entities.PracticeHintAction | ||
import com.github.braillesystems.learnbraille.data.entities.TheoryPassStep | ||
import com.github.braillesystems.learnbraille.utils.Days | ||
import com.github.braillesystems.learnbraille.utils.minus | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.After | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.io.IOException | ||
import java.util.* | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ActionsRepositoryTest { | ||
|
||
private lateinit var db: LearnBrailleDatabase | ||
private lateinit var repo: MutableActionsRepository | ||
private val currDate = Date() | ||
private val actions = arrayOf( | ||
Action(id = 1, type = TheoryPassStep(isInput = false)), | ||
Action(id = 2, type = PracticeHintAction, date = currDate - Days(50)) | ||
) | ||
|
||
@Before | ||
fun createDB() { | ||
val context = InstrumentationRegistry.getInstrumentation().targetContext | ||
db = Room | ||
.inMemoryDatabaseBuilder(context, LearnBrailleDatabase::class.java) | ||
.allowMainThreadQueries() | ||
.build().apply { | ||
runBlocking { | ||
actionDao.insert(*actions) | ||
} | ||
} | ||
repo = ActionsRepositoryImpl( | ||
db.actionDao, | ||
getCurrDate = { currDate }, | ||
keepActionsTime = Days(100) | ||
) | ||
} | ||
|
||
@After | ||
@Throws(IOException::class) | ||
fun closeDB() { | ||
db.close() | ||
} | ||
|
||
@Test | ||
fun getAll() = runBlocking { | ||
assertEquals(actions.toList(), repo.getActionsFrom(Days(100))) | ||
} | ||
|
||
@Test | ||
fun rejectLast() = runBlocking { | ||
assertEquals(listOf(actions.first()), repo.getActionsFrom(Days(10))) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ class PracticeRepositoryTest { | |
|
||
@Test | ||
fun practiceRepo() { | ||
TODO() | ||
// TODO | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ class TheoryRepositoryTest { | |
|
||
@Test | ||
fun theoryRepo() { | ||
TODO() | ||
// TODO | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ class DotsCheckerTest { | |
|
||
@Test | ||
fun dotsChecker() { | ||
TODO() | ||
// TODO | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/androidTest/java/com/github/braillesystems/learnbraille/utils/_KotlinTest.kt
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,33 @@ | ||
package com.github.braillesystems.learnbraille.utils | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
|
||
@RunWith(AndroidJUnit4::class) | ||
class KotlinTest { | ||
|
||
private fun getNextNumber(currentNumber: Int, nextNumbers: Array<Int>, repeat: Int): Int? { | ||
var i = 0 | ||
fun getNextNumber(): Int { | ||
return nextNumbers[i++] | ||
} | ||
|
||
fun ifNumberSameAsCurrent(number: Int) = number == currentNumber | ||
|
||
return tryN(repeat, { !ifNumberSameAsCurrent(it) }, { getNextNumber() }) | ||
} | ||
|
||
@Test | ||
fun tryNTest() { | ||
// testing how tryN helps to find first number in a sequence different from specified number | ||
assertEquals(1, getNextNumber(0, arrayOf(1, 1, 1), 2)) | ||
assertEquals(2, getNextNumber(1, arrayOf(1, 2, 3), 2)) | ||
assertEquals(2, getNextNumber(1, arrayOf(1, 2, 3), 3)) | ||
assertEquals(null, getNextNumber(1, arrayOf(1, 2, 3), 1)) | ||
assertEquals(5, getNextNumber(0, arrayOf(0, 0, 0, 5, 1, 0, 4), 4)) | ||
|
||
} | ||
} |
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
Oops, something went wrong.