Skip to content

Commit 5c31f33

Browse files
test: add GetLessonUseCaseTest
1 parent c699913 commit 5c31f33

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.d4rk.androidtutorials.java.domain.android;
2+
3+
import static org.junit.Assert.assertSame;
4+
import static org.mockito.Mockito.mock;
5+
import static org.mockito.Mockito.verify;
6+
import static org.mockito.Mockito.when;
7+
8+
import com.d4rk.androidtutorials.java.data.repository.LessonRepository;
9+
10+
import org.junit.Test;
11+
12+
public class GetLessonUseCaseTest {
13+
14+
@Test
15+
public void invokeReturnsLesson() {
16+
LessonRepository repository = mock(LessonRepository.class);
17+
LessonRepository.Lesson lesson = new LessonRepository.Lesson(1, 2, 3);
18+
when(repository.getLesson("intro")).thenReturn(lesson);
19+
GetLessonUseCase useCase = new GetLessonUseCase(repository);
20+
21+
LessonRepository.Lesson result = useCase.invoke("intro");
22+
23+
assertSame(lesson, result);
24+
verify(repository).getLesson("intro");
25+
}
26+
}
27+

0 commit comments

Comments
 (0)