-
Notifications
You must be signed in to change notification settings - Fork 6
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
2a8c391
commit 95b2d51
Showing
4 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -13,5 +13,6 @@ class ExampleUnitTest { | |
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
assertEquals(3, 1 + 1) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ava/com/example/android/architecture/blueprints/todoapp/statistics/StatisticsUtilsTest.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,29 @@ | ||
package com.example.android.architecture.blueprints.todoapp.statistics | ||
|
||
import com.example.android.architecture.blueprints.todoapp.data.Task | ||
import org.hamcrest.Matchers.`is` | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.Test | ||
|
||
class StatisticsUtilsTest { | ||
|
||
// Give meaningful names: subjectUnderTest_actionOrInput_resultState | ||
@Test | ||
fun getActiveAndCompleteStats_noCompleted_returnsHundredZero() { | ||
// Arrange - Given: create an active task | ||
val tasks = listOf<Task>( | ||
Task("title", "description", isCompleted = false) | ||
) | ||
// Act - When: call the function | ||
val result = getActiveAndCompletedStats(tasks) | ||
|
||
// Assert - Then: check the result | ||
/*assertEquals(result.completedTasksPercent, 0f) | ||
assertEquals(result.activeTasksPercent, 100f)*/ | ||
|
||
// use hamcrest | ||
assertThat(result.activeTasksPercent, `is`(100f)) | ||
assertThat(result.completedTasksPercent, `is`(0f)) | ||
} | ||
|
||
} |
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