Skip to content

Instantly share code, notes, and snippets.

@qnoid
Last active December 18, 2015 15:39
Show Gist options
  • Save qnoid/5805664 to your computer and use it in GitHub Desktop.
Save qnoid/5805664 to your computer and use it in GitHub Desktop.
Related gists: ApplicationScope.java https://gist.github.com/qnoid/5805659
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