From f0d8d88e444e2b5456a1519a554db2cfefd58f35 Mon Sep 17 00:00:00 2001 From: Geanik Date: Thu, 19 Oct 2023 21:19:21 +0200 Subject: [PATCH] Add test for UpdateProfileUseCaseImpl --- .../impl/UpdateProfileUseCaseImplTest.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt new file mode 100644 index 00000000..46a45af8 --- /dev/null +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt @@ -0,0 +1,50 @@ +package com.hieuwu.groceriesstore.domain.usecases.impl + +import com.hieuwu.groceriesstore.data.repository.UserRepository +import com.hieuwu.groceriesstore.domain.usecases.UpdateProfileUseCase +import java.util.* +import kotlinx.coroutines.runBlocking +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.Mock +import org.mockito.junit.MockitoJUnitRunner +import org.mockito.kotlin.verify + +@RunWith(MockitoJUnitRunner::class) +class UpdateProfileUseCaseImplTest { + + @Mock + lateinit var mockedUserRepository: UserRepository + private lateinit var testee: UpdateProfileUseCaseImpl + + @Before + fun setUp() { + testee = UpdateProfileUseCaseImpl(userRepository = mockedUserRepository) + } + + @Test + fun whenExecute_thenCallUserRepository() { + val input = + UpdateProfileUseCase.Input( + userId = UUID.randomUUID().toString(), + name = UUID.randomUUID().toString(), + email = UUID.randomUUID().toString(), + phone = UUID.randomUUID().toString(), + address = UUID.randomUUID().toString(), + ) + + runBlocking { + testee.execute(input) + + verify(mockedUserRepository) + .updateUserProfile( + userId = input.userId, + name = input.name, + email = input.email, + phone = input.phone, + address = input.address, + ) + } + } +}