anthony restaino
8 years ago
4 changed files with 63 additions and 1 deletions
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
package acr.browser.lightning.utils; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link Preconditions}. |
||||
*/ |
||||
public class PreconditionsTest { |
||||
|
||||
@Test(expected = RuntimeException.class) |
||||
public void checkNonNull_Null_ThrowsException() { |
||||
Preconditions.checkNonNull(null); |
||||
} |
||||
|
||||
@Test |
||||
public void checkNonNull_NonNull_Succeeds() { |
||||
Preconditions.checkNonNull(new Object()); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
package acr.browser.lightning.utils; |
||||
|
||||
import com.anthonycr.bonsai.Subscription; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Unit tests for {@link SubscriptionUtils}. |
||||
*/ |
||||
public class SubscriptionUtilsTest { |
||||
|
||||
@Test |
||||
public void safeUnsubscribe_NullSubscription_Succeeds() { |
||||
SubscriptionUtils.safeUnsubscribe(null); |
||||
} |
||||
|
||||
@Test |
||||
public void safeUnsubscribe_NonNullSubscription_SuccessfullyUnsubscribes() { |
||||
Subscription subscription = new Subscription() { |
||||
|
||||
boolean isUnsubscribed = false; |
||||
|
||||
@Override |
||||
public void unsubscribe() { |
||||
isUnsubscribed = true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isUnsubscribed() { |
||||
return isUnsubscribed; |
||||
} |
||||
}; |
||||
|
||||
Assert.assertFalse(subscription.isUnsubscribed()); |
||||
|
||||
SubscriptionUtils.safeUnsubscribe(subscription); |
||||
|
||||
Assert.assertTrue(subscription.isUnsubscribed()); |
||||
} |
||||
} |
Loading…
Reference in new issue