-
Notifications
You must be signed in to change notification settings - Fork 6
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 #32 from fattmerchantorg/release/1.2.2
Release/1.2.2
- Loading branch information
Showing
3 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
cardpresent/src/androidTest/java/com/fattmerchant/cpresent/InitializeDriversTest.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,46 @@ | ||
package com.fattmerchant.cpresent | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.runner.AndroidJUnit4 | ||
import com.fattmerchant.android.MobileReaderDriverRepository | ||
import com.fattmerchant.omni.data.MobileReaderDriver | ||
import com.fattmerchant.omni.data.models.Merchant | ||
import com.fattmerchant.omni.data.models.OmniException | ||
import com.fattmerchant.omni.usecase.InitializeDrivers | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class InitializeDriversTest { | ||
|
||
@Test | ||
fun initializationFailsIfNoCredsProvided() { | ||
// Setup | ||
var error: OmniException? = null | ||
val expectedError = MobileReaderDriver.InitializeMobileReaderDriverException("emv_password not found") | ||
val merchant = Merchant().apply { | ||
// Note that the empty map will cause the ChipDnaDriver to never get the creds it needs to initialize itself | ||
options = mapOf() | ||
} | ||
val args = mapOf( | ||
"appContext" to ApplicationProvider.getApplicationContext(), | ||
"appId" to "123", | ||
"merchant" to merchant | ||
) | ||
val job = InitializeDrivers(MobileReaderDriverRepository(), args, Dispatchers.Default) | ||
|
||
// Start the job and capture the error | ||
runBlocking { | ||
job.start { | ||
error = it | ||
} | ||
} | ||
|
||
// Assert that the error returned is the expected one | ||
assertEquals(error?.message, expectedError.message) | ||
assertEquals(error?.detail, expectedError.detail) | ||
} | ||
} |
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