Skip to content

Commit

Permalink
Move error tests to separate test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
mg6maciej committed Apr 4, 2015
1 parent d099ba6 commit bcac6e2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package pl.mg6.testsupport;

import junit.framework.TestCase;

import pl.mg6.testsupport.data.WithNonStaticCreator;
import pl.mg6.testsupport.data.WithProtectedCreator;

public class ReparcelerErrorTestCase extends TestCase {

private final Reparceler reparceler = new Reparceler();

public void testWithProtectedCreatorShouldFail() {
WithProtectedCreator original = new WithProtectedCreator();
ReparcelingResult<WithProtectedCreator> result = reparceler.reparcel(original);
assertSame(original, result.getOriginal());
assertNull(result.getReparceled());
assertTrue(result.getError() instanceof ReparcelingError);
assertEquals("Missing public static CREATOR field on class WithProtectedCreator.", result.getError().getMessage());
}

public void testWithoutCreatorShouldFail() {
WithNonStaticCreator original = new WithNonStaticCreator();
ReparcelingResult<WithNonStaticCreator> result = reparceler.reparcel(original);
assertSame(original, result.getOriginal());
assertNull(result.getReparceled());
assertTrue(result.getError() instanceof ReparcelingError);
assertEquals("Missing public static CREATOR field on class WithNonStaticCreator.", result.getError().getMessage());
}
}
20 changes: 0 additions & 20 deletions src/androidTest/java/pl/mg6/testsupport/ReparcelerTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import pl.mg6.testsupport.data.Hrisey;
import pl.mg6.testsupport.data.Parceler;
import pl.mg6.testsupport.data.Simple;
import pl.mg6.testsupport.data.WithNonStaticCreator;
import pl.mg6.testsupport.data.WithProtectedCreator;

public class ReparcelerTestCase extends TestCase {

Expand Down Expand Up @@ -63,22 +61,4 @@ public void testComplexParcelableShouldBeEqual() {
assertTrue(result.areEqual());
assertNull(result.getError());
}

public void testWithProtectedCreatorShouldFail() {
WithProtectedCreator original = new WithProtectedCreator();
ReparcelingResult<WithProtectedCreator> result = reparceler.reparcel(original);
assertSame(original, result.getOriginal());
assertNull(result.getReparceled());
assertTrue(result.getError() instanceof ReparcelingError);
assertEquals("Missing public static CREATOR field on class WithProtectedCreator.", result.getError().getMessage());
}

public void testWithoutCreatorShouldFail() {
WithNonStaticCreator original = new WithNonStaticCreator();
ReparcelingResult<WithNonStaticCreator> result = reparceler.reparcel(original);
assertSame(original, result.getOriginal());
assertNull(result.getReparceled());
assertTrue(result.getError() instanceof ReparcelingError);
assertEquals("Missing public static CREATOR field on class WithNonStaticCreator.", result.getError().getMessage());
}
}

0 comments on commit bcac6e2

Please sign in to comment.