public void testBuildsIntentWithMultipleOptions() { builder.asSquare().withMaxSize(200, 200); Intent intent = builder.getIntent(activity); assertThat(intent.getIntExtra("aspect_x", 0)).isEqualTo(1); assertThat(intent.getIntExtra("aspect_y", 0)).isEqualTo(1); assertThat(intent.getIntExtra("max_x", 0)).isEqualTo(200); assertThat(intent.getIntExtra("max_y", 0)).isEqualTo(200); }
public void testOutputUriSetAsExtra() { Intent intent = builder.getIntent(activity); Uri output = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT); assertThat(output.toString()).isEqualTo("image:output"); }
@Test public void humanDescriptionJoinWorks() { Binding one = new TestBinding("one"); Binding two = new TestBinding("two"); Binding three = new TestBinding("three"); String actual1 = extraBinderGenerator.emitHumanDescription(asList(one)); assertThat(actual1).isEqualTo("one"); String actual2 = extraBinderGenerator.emitHumanDescription(asList(one, two)); assertThat(actual2).isEqualTo("one and two"); String actual3 = extraBinderGenerator.emitHumanDescription(asList(one, two, three)); assertThat(actual3).isEqualTo("one, two, and three"); }
@Test public void shouldHaveCorrectConfiguration() { if ("debug".equals(BuildConfig.BUILD_TYPE)) { assertThat(BuildConfig.DEBUG).isTrue(); } else if ("release".equals(BuildConfig.BUILD_TYPE)) { assertThat(BuildConfig.DEBUG).isFalse(); } else { fail("build type configuration not tested or supported?"); } } }
@Test public void testCollection() throws Exception { List collection1 = Arrays.asList(new String[]{"A"}); List collection2 = Arrays.asList(new String[]{"B"}); int result = comparator.compare(collection1, collection2); assertThat(result).isEqualTo(1); } }
@Test public void testGetFileSystem() { final URI newRepo = URI.create( "git://new-repo-name" ); final FileSystem fs = PROVIDER.newFileSystem( newRepo, EMPTY_ENV ); assertThat( fs ).isNotNull(); assertThat( PROVIDER.getFileSystem( newRepo ) ).isEqualTo( fs ); assertThat( PROVIDER.getFileSystem( URI.create( "git://master@new-repo-name" ) ) ).isEqualTo( fs ); assertThat( PROVIDER.getFileSystem( URI.create( "git://branch@new-repo-name" ) ) ).isEqualTo( fs ); assertThat( PROVIDER.getFileSystem( URI.create( "git://branch@new-repo-name?fetch" ) ) ).isEqualTo( fs ); }
@Test public void bindingKnownPackagesIsNoOp() { bind(new Activity()); bindNavigationModel(new Object(), new Activity()); assertThat(EXTRA_BINDERS).isEmpty(); assertThat(NAVIGATION_MODEL_BINDERS).isEmpty(); } }
@Test public void givenAnAnimationIsNotPartOfASetWhenWeAskThenItSaysItsANewAnimation() throws Exception { boolean startOfANewAnimation = tracker.isTheStartOfANewAnimationSet("TestKey", ANY_DURATION); assertThat(startOfANewAnimation).isTrue(); }
@Test public void testURLSafe() { String uuid = uuidGenerator.newUuidBase64(); assertThat(uuid.contains("\u003d")).isFalse(); assertThat(uuid.contains("\u002f")).isFalse(); assertThat(uuid.contains("\u002b")).isFalse(); assertThat(uuid.contains("\u0026")).isFalse(); }
@Test public void debugTest() { Timber.plant(new Timber.DebugTree()); logger.debug("Hello, world!"); List<LogItem> logs = ShadowLog.getLogs(); assertThat(logs).hasSize(1); LogItem log = logs.get(0); assertThat(log.type).isEqualTo(Log.DEBUG); assertThat(log.tag).isEqualTo("TimberLoggerAdapterTest"); assertThat(log.msg).isEqualTo("Hello, world!"); assertThat(log.throwable).isNull(); } }
@Test public void illegalStartOfTokenCharactersFailFast() { try { from("blah {NoUppercaseAllowed}"); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("Unexpected first character 'N'; must be lower case a-z."); } }
@Test public void twiceWillReturnDoubleTheInput() { int actual = doubler.twice(HALF); int expected = WHOLE; assertThat(actual).isEqualTo(expected); }
@Test public void testGetFileStore() throws Exception { final URI newRepo = URI.create( "git://filestore-test-repo" ); PROVIDER.newFileSystem( newRepo, EMPTY_ENV ); final Path path = PROVIDER.getPath( URI.create( "git://master@filestore-test-repo/path/to/myfile1.txt" ) ); final OutputStream outStream = PROVIDER.newOutputStream( path ); outStream.write( "my cool content".getBytes() ); outStream.close(); final FileStore fileStore = PROVIDER.getFileStore( path ); assertThat( fileStore ).isNotNull(); assertThat( fileStore.getAttribute( "readOnly" ) ).isEqualTo( Boolean.FALSE ); }
@Test public void zeroInjectionsInjectDoesNotThrowException() { class Example {} Example example = new Example(); bind(example, null); bindNavigationModel(example, null, null); assertThat(EXTRA_BINDERS).contains(entry(Example.class, NO_OP)); assertThat(NAVIGATION_MODEL_BINDERS).contains(entry(Example.class, NO_OP)); }
@Test public void givenTwoAnimationsAreNotPartOfASetWhenWeAskThenThereIsTwoIncrements() throws Exception { tracker.isTheStartOfANewAnimationSet("TestKey1", ANY_DURATION); boolean startOfANewAnimation = tracker.isTheStartOfANewAnimationSet("TestKey2", ANY_DURATION); assertThat(startOfANewAnimation).isTrue(); }
@Test public void whenQueryingIsPlaying_thenReturnsFalse() { boolean isPlaying = player.isPlaying(); assertThat(isPlaying).isFalse(); }
public void testAspectRatioSetAsExtras() { builder.withAspect(16, 10); Intent intent = builder.getIntent(activity); assertThat(intent.getIntExtra("aspect_x", 0)).isEqualTo(16); assertThat(intent.getIntExtra("aspect_y", 0)).isEqualTo(10); }
@Test public void testSimpleBranchedGitRoot() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "/", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/"); assertThat(path.getRoot().toString()).isEqualTo("/"); assertThat(path.getNameCount()).isEqualTo(0); }
@Test public void intoSetsTargetText() { Context context = RuntimeEnvironment.application; TextView textView = new TextView(context); Phrase.from("Hello {user}!").put("user", "Eric").into(textView); CharSequence actual = textView.getText().toString(); assertThat(actual.toString()).isEqualTo("Hello Eric!"); }
@Test public void testUUIDLength() { String uuid = uuidGenerator.newUuidBase64(); assertThat(uuid.length()).isEqualTo(22); }