@UsesMocks({SocializeConfig.class, MockContext.class, Intent.class})
  public void test_registerC2DM() {
    final String senderId = "foobar";

    NotificationRegistrationState notificationRegistrationState =
        AndroidMock.createMock(NotificationRegistrationState.class);
    SocializeConfig config = AndroidMock.createMock(SocializeConfig.class);
    MockContext context = AndroidMock.createNiceMock(MockContext.class);
    final Intent registrationIntent = AndroidMock.createMock(Intent.class);

    AndroidMock.expect(notificationRegistrationState.isC2dmPending()).andReturn(false);

    notificationRegistrationState.setC2dmPendingRequestTime(AndroidMock.anyLong());
    notificationRegistrationState.save(context);

    AndroidMock.expect(config.getProperty(SocializeConfig.SOCIALIZE_C2DM_SENDER_ID))
        .andReturn(senderId);

    AndroidMock.expect(
            registrationIntent.putExtra(
                SocializeNotificationRegistrationSystem.EXTRA_APPLICATION_PENDING_INTENT,
                (PendingIntent) null))
        .andReturn(registrationIntent);
    AndroidMock.expect(
            registrationIntent.putExtra(
                SocializeNotificationRegistrationSystem.EXTRA_SENDER, senderId))
        .andReturn(registrationIntent);
    AndroidMock.expect(context.startService(registrationIntent)).andReturn(null);

    AndroidMock.replay(notificationRegistrationState, config, context, registrationIntent);

    SocializeNotificationRegistrationSystem system =
        new SocializeNotificationRegistrationSystem() {
          @Override
          public boolean isRegisteredC2DM() {
            return false;
          }

          @Override
          protected Intent newIntent(String action) {
            return registrationIntent;
          }

          @Override
          protected PendingIntent newPendingIntent(Context context) {
            return null;
          }
        };

    system.setConfig(config);
    system.setNotificationRegistrationState(notificationRegistrationState);

    system.registerC2DM(context);

    AndroidMock.verify(notificationRegistrationState, config, context, registrationIntent);
  }
  public void test_isRegistrationPending() {
    NotificationRegistrationState notificationRegistrationState =
        AndroidMock.createMock(NotificationRegistrationState.class);

    AndroidMock.expect(notificationRegistrationState.isC2dmPending()).andReturn(true);
    AndroidMock.replay(notificationRegistrationState);

    SocializeNotificationRegistrationSystem system = new SocializeNotificationRegistrationSystem();

    system.setNotificationRegistrationState(notificationRegistrationState);

    assertTrue(system.isRegistrationPending());

    AndroidMock.verify(notificationRegistrationState);
  }