-
Notifications
You must be signed in to change notification settings - Fork 0
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
AdrianBalunan
committed
Mar 4, 2026
1 parent
7d6fe90
commit 7fa8603
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/SettingsTest.java
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,72 @@ | ||
| package ntnu.systemutvikling.team6.models; | ||
|
|
||
| import ntnu.sytemutvikling.team6.models.Language; | ||
| import ntnu.sytemutvikling.team6.models.Settings; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| class SettingsTest { | ||
|
|
||
| @Test | ||
| void testDefaultConstructorSetsStandardValues() { | ||
| Settings settings = new Settings(); | ||
|
|
||
| assertTrue(settings.isLightMode()); | ||
| assertEquals(Language.ENGLISH, settings.getLanguage()); | ||
| assertFalse(settings.isAnonymous()); | ||
| } | ||
|
|
||
| @Test | ||
| void testCustomConstructorSetsValuesCorrectly() { | ||
| Settings settings = new Settings(false, Language.ENGLISH, true); | ||
|
|
||
| assertFalse(settings.isLightMode()); | ||
| assertEquals(Language.ENGLISH, settings.getLanguage()); | ||
| assertTrue(settings.isAnonymous()); | ||
| } | ||
|
|
||
| @Test | ||
| void testConstructorThrowsExceptionWhenLanguageIsNull() { | ||
| assertThrows(IllegalArgumentException.class, | ||
| () -> new Settings(true, null, false)); | ||
| } | ||
|
|
||
| @Test | ||
| void testToggleLightMode() { | ||
| Settings settings = new Settings(true, Language.ENGLISH, false); | ||
|
|
||
| settings.toggleLightMode(); | ||
| assertFalse(settings.isLightMode()); | ||
|
|
||
| settings.toggleLightMode(); | ||
| assertTrue(settings.isLightMode()); | ||
| } | ||
|
|
||
| @Test | ||
| void testToggleAnonymousMode() { | ||
| Settings settings = new Settings(true, Language.ENGLISH, false); | ||
|
|
||
| settings.toggleAnonymousMode(); | ||
| assertTrue(settings.isAnonymous()); | ||
|
|
||
| settings.toggleAnonymousMode(); | ||
| assertFalse(settings.isAnonymous()); | ||
| } | ||
|
|
||
| @Test | ||
| void testChangeLanguageSuccessfully() { | ||
| Settings settings = new Settings(); | ||
|
|
||
| settings.changeLanguage(Language.ENGLISH); | ||
| assertEquals(Language.ENGLISH, settings.getLanguage()); | ||
| } | ||
|
|
||
| @Test | ||
| void testChangeLanguageThrowsExceptionWhenNull() { | ||
| Settings settings = new Settings(); | ||
|
|
||
| assertThrows(IllegalArgumentException.class, | ||
| () -> settings.changeLanguage(null)); | ||
| } | ||
| } |