File tree Expand file tree Collapse file tree
app/src/test/kotlin/com/vrem/wifianalyzer/settings Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,28 +40,42 @@ class LanguagePreferenceTest {
4040
4141 @Test
4242 fun entries () {
43+ // setup
44+ val expected =
45+ languageTags
46+ .filter { it.isNotEmpty() }
47+ .map { tag ->
48+ val locale = Locale .forLanguageTag(tag)
49+ locale.getDisplayName(locale).titlecaseFirst(locale)
50+ }.sorted()
51+
4352 // execute
4453 val actual: Array <CharSequence > = fixture.entries
54+
4555 // validate
4656 assertThat(actual).hasSize(languageTags.size)
47-
48- // Check system default entry
4957 assertThat(actual[0 ]).isEqualTo(mainActivity.getString(R .string.system_default))
50-
51- // Check language entries
52- languageTags.drop(1 ).forEachIndexed { index, tag ->
53- val locale = Locale .forLanguageTag(tag)
54- val displayName = locale.getDisplayName(locale).titlecaseFirst(locale)
55- assertThat(actual[index + 1 ]).isEqualTo(displayName)
56- }
58+ assertThat(actual.drop(1 )).containsExactlyElementsOf(expected)
5759 }
5860
5961 @Test
6062 fun entryValues () {
63+ // setup
64+ val expected =
65+ languageTags
66+ .filter { it.isNotEmpty() }
67+ .map { tag ->
68+ val locale = Locale .forLanguageTag(tag)
69+ Data (tag, locale.getDisplayName(locale).titlecaseFirst(locale))
70+ }.sorted()
71+ .map { it.code }
72+
6173 // execute
6274 val actual: Array <CharSequence > = fixture.entryValues
75+
6376 // validate
6477 assertThat(actual).hasSize(languageTags.size)
65- assertThat(actual).containsExactlyElementsOf(languageTags)
78+ assertThat(actual[0 ]).isEqualTo(" " )
79+ assertThat(actual.drop(1 )).containsExactlyElementsOf(expected)
6680 }
6781}
You can’t perform that action at this time.
0 commit comments