-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c196d4
commit 7d8677b
Showing
3 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
12 changes: 4 additions & 8 deletions
12
MockitoKotlinStatic/app/src/main/res/layout/activity_main.xml
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 |
---|---|---|
@@ -1,19 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
<FrameLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
<TextView | ||
android:id="@+id/txtMsg" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"/> | ||
android:text="Hello World!"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</FrameLayout> |
45 changes: 45 additions & 0 deletions
45
...toKotlinStatic/app/src/test/java/com/aykutasil/mockitokotlinstatic/StaffRepositoryTest.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,45 @@ | ||
package com.aykutasil.mockitokotlinstatic | ||
|
||
import com.nhaarman.mockitokotlin2.* | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.mockito.ArgumentMatchers.anyString | ||
|
||
class StaffRepositoryTest { | ||
|
||
private lateinit var staffRepository: StaffRepository | ||
private val staffDao: StaffDao = mock() | ||
private val logUtil: LogUtil = mock() | ||
|
||
@Before | ||
fun setUp() { | ||
staffRepository = StaffRepository(staffDao, logUtil) | ||
} | ||
|
||
@Test | ||
fun `staff should save if it's name is not null`() { | ||
val staff = Staff(name = "Aykut") | ||
staffRepository.saveLocalRepo(staff) | ||
|
||
verify(staffDao).save() | ||
verify(staffDao, atLeastOnce()).save() | ||
verify(staffDao, only()).save() | ||
|
||
verify(logUtil).i(anyString()) | ||
} | ||
|
||
@Test | ||
fun `staff should not save if it's name is null`() { | ||
val staff = Staff() | ||
staffRepository.saveLocalRepo(staff) | ||
verify(staffDao, never()).save() | ||
} | ||
|
||
@Test | ||
fun `staff should save if internet connection is OK`() { | ||
val staff = Staff() | ||
staffRepository.saveRemoteRepo(staff) | ||
verify(staffDao, never()).save() | ||
} | ||
|
||
} |
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