Created
February 3, 2017 15:37
-
-
Save ecgreb/671efdcec7a5b5f337960c8c66819521 to your computer and use it in GitHub Desktop.
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
public class ResourceManagerTest { | |
private TestResources resources = new TestResources(); | |
private ResourceManager resourceManager = new ResourceManager(resources); | |
@Test public void shouldNotBeNull() throws Exception { | |
assertThat(resourceManager).isNotNull(); | |
} | |
@Test public void getTitle_true_shouldReturnSuccessTitle() throws Exception { | |
assertThat(resourceManager.getTitle(true)).isEqualTo("Success"); | |
} | |
@Test public void getTitle_false_shouldReturnErrorTitle() throws Exception { | |
assertThat(resourceManager.getTitle(false)).isEqualTo("Error"); | |
} | |
@Test public void getDescription_true_shouldReturnSuccessDescription() throws Exception { | |
assertThat(resourceManager.getDescription(true)).isEqualTo("Congrats you did it!"); | |
} | |
@Test public void getDescription_false_shouldReturnErrorDescription() throws Exception { | |
assertThat(resourceManager.getDescription(false)).isEqualTo("Uh oh something went wrong"); | |
} | |
private class TestResources extends Resources { | |
public TestResources() { | |
super(null, null, null); | |
} | |
@NonNull @Override public String getString(int id) throws NotFoundException { | |
switch (id) { | |
case R.string.success_title: | |
return "Success"; | |
case R.string.error_title: | |
return "Error"; | |
case R.string.success_description: | |
return "Congrats you did it!"; | |
case R.string.error_description: | |
return "Uh oh something went wrong"; | |
} | |
throw new NotFoundException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment