@Test
  public void testScoreSeriesEpisodeCounts() {

    ResultDescription desc = desc();
    assertThat(
        scorer.scoreSortedSeriesSizes(list(1, 2, 3, 4), list(1, 2, 3, 4), "candidate", desc),
        is(Score.ONE));
    assertThat(
        scorer.scoreSortedSeriesSizes(list(1, 2, 3, 4, 5), list(1, 2, 3, 4), "candidate", desc),
        is(Score.ONE));
    assertThat(
        scorer.scoreSortedSeriesSizes(list(1, 2, 3, 4), list(1, 3, 4), "candidate", desc),
        is(Score.ONE));
    assertThat(
        scorer.scoreSortedSeriesSizes(list(1, 2, 3, 6), list(1, 3, 5), "candidate", desc),
        is(Score.ONE));

    assertThat(
        scorer.scoreSortedSeriesSizes(list(6, 6), list(24, 24), "candidate", desc),
        is(Score.nullScore()));
    assertThat(
        scorer.scoreSortedSeriesSizes(list(6, 6), list(6, 24, 24), "candidate", desc),
        is(Score.nullScore()));
    assertThat(
        scorer.scoreSortedSeriesSizes(list(2, 3, 4), list(3, 4, 6, 7), "candidate", desc),
        is(Score.nullScore()));
  }
  @Test
  @SuppressWarnings("unchecked")
  public void testScoresNullWhenFlatContainerWithChildCountsOutOfRange() {

    ScoredCandidates<Container> score =
        scorer.score(
            brandWithChildren(5), ImmutableSet.<Container>of(brandWithChildren(7)), desc());

    assertThat(Iterables.getOnlyElement(score.candidates().values()), is(Score.nullScore()));
    verify(contentResolver, never()).findByCanonicalUris((Iterable<String>) any());
  }
  @Test
  @SuppressWarnings("unchecked")
  public void testScoresNullWhenFlatSubjectHasNoEpisodes() {

    Brand subject = brandWithChildren(0);
    Brand candidate = brandWithChildren(1);

    ScoredCandidates<Container> score = scorer.score(subject, ImmutableSet.of(candidate), desc());

    assertThat(Iterables.getOnlyElement(score.candidates().values()), is(Score.nullScore()));
    verify(contentResolver, never()).findByCanonicalUris((Iterable<String>) any());
  }
  @Test
  public void testScoresNullWhenSeriesContainerWithSeriesCountsOutOfRange() {

    final Brand subject = brandWithSeries(5);

    when(contentResolver.findByCanonicalUris(
            ImmutableList.copyOf(Iterables.transform(subject.getSeriesRefs(), SeriesRef.TO_URI))))
        .thenReturn(ResolvedContent.builder().putAll(series(5)).build());

    ScoredCandidates<Container> score =
        scorer.score(subject, ImmutableSet.<Container>of(brandWithSeries(7)), desc());

    assertThat(Iterables.getOnlyElement(score.candidates().values()), is(Score.nullScore()));
  }
  @Test
  @SuppressWarnings("unchecked")
  public void testScoresNullWhenCandidateHasNoSeries() {

    Brand subject = brandWithSeries(1);
    Brand candidate = brandWithSeries(0);

    when(contentResolver.findByCanonicalUris(
            ImmutableList.copyOf(Iterables.transform(subject.getSeriesRefs(), SeriesRef.TO_URI))))
        .thenReturn(ResolvedContent.builder().putAll(series(1)).build());

    ScoredCandidates<Container> score = scorer.score(subject, ImmutableSet.of(candidate), desc());

    assertThat(Iterables.getOnlyElement(score.candidates().values()), is(Score.nullScore()));
    verify(contentResolver).findByCanonicalUris((Iterable<String>) any());
  }