50 lines
1.4 KiB
Kotlin
50 lines
1.4 KiB
Kotlin
package com.example.hpostesting
|
|
|
|
import android.content.Context
|
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
|
import com.example.hpostesting.data.repository.Repository
|
|
import com.example.hpostesting.presentation.deviceinfo.DeviceViewModel
|
|
import org.junit.Before
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
import org.mockito.Mock
|
|
import org.mockito.junit.MockitoJUnitRunner
|
|
|
|
@RunWith(MockitoJUnitRunner::class)
|
|
class DeviceViewModelTest {
|
|
|
|
@get:Rule
|
|
val rule = InstantTaskExecutorRule()
|
|
|
|
@Mock
|
|
private lateinit var hemoCubeDao: HemoCubeDao
|
|
|
|
@Mock
|
|
private lateinit var repository: Repository
|
|
|
|
@Mock
|
|
private lateinit var context: Context
|
|
|
|
private lateinit var viewModel: DeviceViewModel
|
|
|
|
@Before
|
|
fun setup() {
|
|
viewModel = DeviceViewModel(hemoCubeDao, repository)
|
|
}
|
|
|
|
@Test
|
|
fun `test initial state`() {
|
|
assert(!viewModel.isServiceConnected)
|
|
assert(!viewModel.progressBar.value!!)
|
|
assert(viewModel.messages.value == null)
|
|
// assert(viewModel.allUserData == hemoCubeDao.getAll())
|
|
// assert(viewModel.deviceData.value == null)
|
|
// assert(viewModel.networkStatusLiveData.value == false)
|
|
assert(viewModel.fireBaseUpload.value == null)
|
|
}
|
|
|
|
// Add more tests for other functions and interactions as needed
|
|
}
|