Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aykuttasil committed Feb 1, 2019
1 parent 4c196d4 commit 7d8677b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
12 changes: 4 additions & 8 deletions MockitoKotlinStatic/app/src/main/res/layout/activity_main.xml
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>
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()
}

}
2 changes: 2 additions & 0 deletions update_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ do
p=$(dirname "${line}");
echo "Copying versions.gradle -> ${p}";
cp versions.gradle "$p"

cp gradle.properties "$p"

# remove the "ADMIN" line from the samples themselves
extraArg=""
Expand Down

0 comments on commit 7d8677b

Please sign in to comment.