@Test
 public void constructor_shouldInitializeMembers() throws Exception {
   assertThat(subject.getImpressionMinPercentageViewed()).isEqualTo(50);
   assertThat(subject.getImpressionMinTimeViewed()).isEqualTo(1000);
   assertThat(subject.getImpressionTrackers()).isEmpty();
   assertThat(subject.getExtras()).isEmpty();
 }
  @Test
  public void setImpressionMinTimeViewed_whenTimeIsLessThan0_shouldNotSetTime() throws Exception {
    subject.setImpressionMinTimeViewed(250);
    assertThat(subject.getImpressionMinTimeViewed()).isEqualTo(250);

    subject.setImpressionMinTimeViewed(-1);
    assertThat(subject.getImpressionMinTimeViewed()).isEqualTo(250);
  }
  @Test
  public void setStarRating_withNull_shouldSetStarRatingToNull() throws Exception {
    // Setting star rating to 0 before each case, so we can detect when it gets set to null
    final double initialStarRating = 0.0;

    subject.setStarRating(initialStarRating);
    subject.setStarRating(null);
    assertThat(subject.getStarRating()).isEqualTo(null);
  }
  @Before
  public void setUp() throws Exception {
    Activity context = Robolectric.buildActivity(Activity.class).create().get();
    relativeLayout = new RelativeLayout(context);
    relativeLayout.setId((int) Utils.generateUniqueId());
    viewGroup = new LinearLayout(context);

    BaseForwardingNativeAd baseForwardingNativeAd = new BaseForwardingNativeAd() {};
    baseForwardingNativeAd.setTitle("test title");
    baseForwardingNativeAd.setText("test text");
    baseForwardingNativeAd.setCallToAction("test call to action");
    baseForwardingNativeAd.setClickDestinationUrl("destinationUrl");

    nativeResponse =
        new NativeResponse(
            context,
            "impressionTrackerUrl",
            "clickTrackerUrl",
            "test ID",
            baseForwardingNativeAd,
            mock(MoPubNative.MoPubNativeListener.class));

    titleView = new TextView(context);
    titleView.setId((int) Utils.generateUniqueId());
    textView = new TextView(context);
    textView.setId((int) Utils.generateUniqueId());
    callToActionView = new Button(context);
    callToActionView.setId((int) Utils.generateUniqueId());
    mainImageView = new ImageView(context);
    mainImageView.setId((int) Utils.generateUniqueId());
    iconImageView = new ImageView(context);
    iconImageView.setId((int) Utils.generateUniqueId());
    badView = new ImageView(context);
    badView.setId((int) Utils.generateUniqueId());

    relativeLayout.addView(titleView);
    relativeLayout.addView(textView);
    relativeLayout.addView(callToActionView);
    relativeLayout.addView(mainImageView);
    relativeLayout.addView(iconImageView);
    relativeLayout.addView(badView);

    viewBinder =
        new ViewBinder.Builder(relativeLayout.getId())
            .titleId(titleView.getId())
            .textId(textView.getId())
            .callToActionId(callToActionView.getId())
            .mainImageId(mainImageView.getId())
            .iconImageId(iconImageView.getId())
            .build();

    subject = new MoPubNativeAdRenderer(viewBinder);
  }
  @Test
  public void setStarRating_withValuesOutsideOfValidRange_shouldNotSetStarRating()
      throws Exception {
    // First, set star rating to a valid value
    final double initialStarRating = 4.9;
    subject.setStarRating(initialStarRating);

    subject.setStarRating(5.0001);
    assertThat(subject.getStarRating()).isEqualTo(initialStarRating);

    subject.setStarRating(-0.001);
    assertThat(subject.getStarRating()).isEqualTo(initialStarRating);
  }
  @Test
  public void setStarRating_withinValidRange_shouldSetStarRating() throws Exception {
    subject.setStarRating(0.0);
    assertThat(subject.getStarRating()).isEqualTo(0.0);

    subject.setStarRating(5.0);
    assertThat(subject.getStarRating()).isEqualTo(5.0);

    subject.setStarRating(2.5);
    assertThat(subject.getStarRating()).isEqualTo(2.5);
  }
  @Test
  public void setStarRating_withNanOrInf_shouldNotSetStarRating() throws Exception {
    // First, set star rating to a valid value
    final double initialStarRating = 3.75;
    subject.setStarRating(initialStarRating);

    subject.setStarRating(Double.NaN);
    assertThat(subject.getStarRating()).isEqualTo(initialStarRating);

    subject.setStarRating(Double.POSITIVE_INFINITY);
    assertThat(subject.getStarRating()).isEqualTo(initialStarRating);

    subject.setStarRating(Double.NEGATIVE_INFINITY);
    assertThat(subject.getStarRating()).isEqualTo(initialStarRating);
  }