public void PreferredBiography_ItemsHasOneElement_ReturnsTheOneElement() { var biography = new Biography(); _subject.Items.Add(biography); _subject.PreferredBiography.Should().Be(biography); }
public void PreferredBiography_ItemsHasMoreThenOneBiographyAndOneIsFromLastFM_ReturnsTheBiographyFromLastFm() { var biography1 = new Biography { Site = "wikipedia" }; var biography2 = new Biography { Site = "last.fm" }; _subject.Items.AddRange(new[] { biography1, biography2 }); _subject.PreferredBiography.Should().Be(biography2); }
public void PreferredBiography_ItemsHasMoreThenOneBiographyAndNoneIsFromLastFMButOrWikipedia_ReturnsTheBiographyWithTheLongestText() { var biography1 = new Biography { Site = "test", Text = "test123" }; var biography2 = new Biography { Site = "test2", Text = "test1234" }; _subject.Items.AddRange(new[] { biography1, biography2 }); _subject.PreferredBiography.Should().Be(biography2); }
private int GetScore(Biography biography) { var maximumBiographyLength = Items.Max(item => item.Text != null ? item.Text.Length : 0); var score = BiographyPrioritiesEnum.None; if (biography.Site == LastFmSiteName) { score |= BiographyPrioritiesEnum.LastFm; } if (biography.Site == WikipediaSiteName) { score |= BiographyPrioritiesEnum.Wikipedia; } if (biography.Text != null && biography.Text.Length == maximumBiographyLength) { score |= BiographyPrioritiesEnum.LongestText; } return (int)score; }
private int GetScore(Biography biography) { var maximumBiographyLength = Items.Max(item => item.Text != null ? item.Text.Length : 0); var score = BiographyPrioritiesEnum.None; if (biography.Site == LastFmSiteName) { score |= BiographyPrioritiesEnum.LastFm; } if (biography.Site == WikipediaSiteName) { score |= BiographyPrioritiesEnum.Wikipedia; } if (biography.Text != null && biography.Text.Length == maximumBiographyLength) { score |= BiographyPrioritiesEnum.LongestText; } return((int)score); }
public async Task Populate_BiographiesHasItems_SetsTheBestBiographyOnTheViewModel() { var biography1 = new Biography { Text = "test1", Site = "wikipedia" }; var biography2 = new Biography { Text = "test2", Site = "last.fm" }; var biographies = new Biographies { Items = new List <Biography> { biography1, biography2 } }; _mockEchoNestService.SetupGetArtistBiographies(artistName => new MockGetBiographiesResult(artistName) { GetResultFunc = () => biographies }); await _subject.Populate(); _subject.Biography.Should().Be("test2"); }
public async Task Populate_BiographiesHasItems_SetsTheBestBiographyOnTheViewModel() { var biography1 = new Biography { Text = "test1", Site = "wikipedia" }; var biography2 = new Biography { Text = "test2", Site = "last.fm" }; var biographies = new Biographies { Items = new List<Biography> { biography1, biography2 } }; _mockEchoNestService.SetupGetArtistBiographies(artistName => new MockGetBiographiesResult(artistName) { GetResultFunc = () => biographies }); await _subject.Populate(); _subject.Biography.Text.Should().Be(biography2.Text); }