Last active
December 18, 2015 15:39
-
-
Save qnoid/5805664 to your computer and use it in GitHub Desktop.
Related gists: ApplicationScope.java
https://gist.github.com/qnoid/5805659
This file contains hidden or 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
import org.junit.Test; | |
import org.junit.Assert; | |
import java.util.function.Consumer; | |
public class ApplicationScopeTest | |
{ | |
@Test(expected=RuntimeException.class) | |
public void testApplicationScope() throws Exception | |
{ | |
ApplicationScope applicationScope = new ApplicationScope(); | |
applicationScope.acceptValue(null); | |
} | |
@Test | |
public void testAcceptValue() throws Exception | |
{ | |
ApplicationScope applicationScope = new ApplicationScope(); | |
applicationScope.didCreate("Hello World"); | |
applicationScope.acceptValue( s -> { Assert.assertTrue(s.equals("Hello World")); }); | |
} | |
@Test | |
public void testAcceptSuppliedValue() throws Exception | |
{ | |
ApplicationScope applicationScope = new ApplicationScope( () -> { return "Hello World"; } ); | |
applicationScope.acceptSuppliedValue( s -> { Assert.assertTrue(s.equals("Hello World")); }); | |
} | |
@Test | |
public void testConsumeAcceptedValue() throws Exception | |
{ | |
final ApplicationScope applicationScope = new ApplicationScope(); | |
Consumer<String> consumer = (String s) -> { | |
applicationScope.didCreate(s); | |
}; | |
consumer.accept("Hello World"); | |
applicationScope.acceptValue( s -> { Assert.assertTrue(s.equals("Hello World")); } ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment