public void EnsureGetMixesThrowsExceptionForNullGroup() { MixGroup nullGroup = null; IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes)); client.GetMixesAsync(nullGroup).Wait(); }
/// <summary> /// Routes clicks on an MusicItem to the right place... /// </summary> /// <param name="item">The item.</param> /// <param name="player">The player if the page has one.</param> /// <returns> /// A boolean indicating if we rooted the object successfully /// </returns> public async Task <bool> RouteItemClick(object item, MediaElement player) { Artist artist = item as Artist; if (artist != null) { App.RootFrame.Navigate(typeof(DetailPage), artist); return(true); } Product product = item as Product; UserEvent userEvent = item as UserEvent; if (userEvent != null && userEvent.Product != null) { product = userEvent.Product; } if (product != null) { if (product.Category == Category.Track) { Debug.WriteLine("Track pressed"); await product.Show(); } else if (product.Category == Category.Album) { App.RootFrame.Navigate(typeof(DetailPage), product); } return(true); } Genre genre = item as Genre; if (genre != null) { App.RootFrame.Navigate(typeof(DetailPage), genre); return(true); } MixGroup group = item as MixGroup; if (group != null) { App.RootFrame.Navigate(typeof(ShowListPage), new ShowListParams(MethodCall.GetMixes, group.Id, group.Name)); return(true); } Mix mix = item as Mix; if (mix != null) { await mix.Play(); return(true); } return(false); }
public void TestParamConstructor() { MixGroup group = new MixGroup("1234", "Metal"); Assert.AreEqual("1234", group.Id); Assert.AreEqual("Metal", group.Name); }
/// <summary> /// Routes clicks on an MusicItem to the right place... /// </summary> /// <param name="item">The item.</param> /// <param name="player">The player if the page has one.</param> /// <returns> /// A boolean indicating if we rooted the object successfully /// </returns> public bool RouteItemClick(object item, MediaElement player) { Artist artist = item as Artist; if (artist != null) { App.RootFrame.Navigate(typeof(DetailPage), artist); return(true); } Product product = item as Product; if (product != null) { if (product.Category == Category.Track) { Debug.WriteLine("Track pressed"); ShowProductTask task = new ShowProductTask() { ProductId = product.Id }; task.Show(); } else if (product.Category == Category.Album) { App.RootFrame.Navigate(typeof(DetailPage), product); } return(true); } Genre genre = item as Genre; if (genre != null) { App.RootFrame.Navigate(typeof(DetailPage), genre); return(true); } MixGroup group = item as MixGroup; if (group != null) { App.RootFrame.Navigate(typeof(ShowListPage), new ShowListParams(MethodCall.GetMixes, group.Id, group.Name)); return(true); } Mix mix = item as Mix; if (mix != null) { mix.Play(); return(true); } return(false); }
/// <summary> /// Gets the Mixes available in a group /// </summary> /// <param name="group">The mix group.</param> /// <param name="exclusiveTag">The exclusive tag.</param> /// <returns> /// A ListResponse containing Mixes or an Error /// </returns> public Task <ListResponse <Mix> > GetMixesAsync(MixGroup group, string exclusiveTag) { if (group == null) { throw new ArgumentNullException("group", "group cannot be null"); } return(this.GetMixesAsync(group.Id, exclusiveTag)); }
public void TestOverrides() { MixGroup group = new MixGroup() { Id = TestId, Name = TestName }; Assert.IsNotNull(group.GetHashCode(), "Expected a hash code"); Assert.IsFalse(group.Equals(TestId), "Expected inequality"); }
public void TestProperties() { MixGroup group = new MixGroup() { Id = TestId, Name = TestName }; Assert.AreEqual(TestId, group.Id, "Expected the property to persist"); Assert.AreEqual(TestName, group.Name, "Expected the property to persist"); }
public void TestJsonParsing() { MixGroup group = new MixGroup() { Id = "1234", Name = "Metal" }; JObject json = JObject.Parse("{\"id\":\"1234\",\"name\":\"Metal\"}"); MixGroup fromJson = MixGroup.FromJToken(json) as MixGroup; Assert.IsNotNull(fromJson, "Expected a MixGroup object"); Assert.IsTrue(group.Equals(fromJson), "Expected the same MixGroup"); }
public void SetMixGroupVolume( MixGroup grp, float vol ) { m_MixGroupVolumes[(int)grp] = vol; foreach ( EPSoundEvent snd in m_EPSoundEventList ) { snd.SetVolume ( snd.GetEventVolume() ); } }
/// <summary> /// Routes clicks on an MusicItem to the right place... /// </summary> /// <param name="item">The item.</param> /// <returns>A boolean indicating if we rooted the object successfully</returns> public bool RouteItemClick(object item) { Artist artist = item as Artist; if (artist != null) { string thumb = string.Empty; if (artist.Thumb200Uri != null) { thumb = HttpUtility.UrlEncode(artist.Thumb200Uri.ToString()); } this.RootFrame.Navigate(new Uri("/ArtistPage.xaml?" + App.IdParam + "=" + artist.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(artist.Name) + "&" + App.ThumbParam + "=" + thumb, UriKind.Relative)); return(true); } Product product = item as Product; if (product != null) { if (product.Category == Category.Track) { ShowProductTask task = new ShowProductTask() { ProductId = product.Id }; task.Show(); } else { string thumb = string.Empty; if (product.Thumb200Uri != null) { thumb = HttpUtility.UrlEncode(product.Thumb200Uri.ToString()); } this.RootFrame.Navigate(new Uri("/AlbumPage.xaml?" + App.IdParam + "=" + product.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(product.Name) + "&" + App.ThumbParam + "=" + thumb, UriKind.Relative)); } return(true); } Genre genre = item as Genre; if (genre != null) { this.RootFrame.Navigate(new Uri("/GenrePage.xaml?" + IdParam + "=" + genre.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(genre.Name), UriKind.Relative)); return(true); } MixGroup group = item as MixGroup; if (group != null) { this.RootFrame.Navigate(new Uri("/ShowListPage.xaml?" + ShowListPage.MethodParam + "=" + MethodCall.GetMixes + "&" + IdParam + "=" + group.Id + "&" + NameParam + "=" + HttpUtility.UrlEncode(group.Name), UriKind.Relative)); return(true); } Mix mix = item as Mix; if (mix != null) { PlayMixTask mixPlayer = new PlayMixTask() { MixId = mix.Id }; mixPlayer.Show(); return(true); } return(false); }
/// <summary> /// Routes clicks on an MusicItem to the right place... /// </summary> /// <param name="item">The item.</param> /// <returns>A boolean indicating if we rooted the object successfully</returns> public async Task <bool> RouteItemClick(object item) { Artist artist = item as Artist; if (artist != null) { string thumb = string.Empty; if (artist.Thumb200Uri != null) { thumb = HttpUtility.UrlEncode(artist.Thumb200Uri.ToString()); } string musicbrainzId = string.Empty; if (!string.IsNullOrEmpty(artist.MusicBrainzId)) { musicbrainzId = "&" + App.MbIdParam + "=" + artist.MusicBrainzId; } this.RootFrame.Navigate(new Uri( "/ArtistPage.xaml?" + App.IdParam + "=" + artist.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(artist.Name) + "&" + App.ThumbParam + "=" + thumb + musicbrainzId, UriKind.Relative)); return(true); } Product product = item as Product; if (product != null) { if (product.Category == Category.Track) { ShowProductTask task = new ShowProductTask() { ClientId = ApiKeys.ClientId, ProductId = product.Id }; await task.Show(); } else { string thumb = string.Empty; if (product.Thumb200Uri != null) { thumb = HttpUtility.UrlEncode(product.Thumb200Uri.ToString()); } this.RootFrame.Navigate(new Uri("/AlbumPage.xaml?" + App.IdParam + "=" + product.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(product.Name) + "&" + App.ThumbParam + "=" + thumb, UriKind.Relative)); } return(true); } Genre genre = item as Genre; if (genre != null) { this.RootFrame.Navigate(new Uri("/GenrePage.xaml?" + IdParam + "=" + genre.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(genre.Name), UriKind.Relative)); return(true); } MixGroup group = item as MixGroup; if (group != null) { this.RootFrame.Navigate(new Uri("/ShowListPage.xaml?" + ShowListPage.MethodParam + "=" + MethodCall.GetMixes + "&" + IdParam + "=" + group.Id + "&" + NameParam + "=" + HttpUtility.UrlEncode(group.Name), UriKind.Relative)); return(true); } Mix mix = item as Mix; if (mix != null) { await mix.Play(); return(true); } return(false); }
/// <summary> /// Gets the Mixes available in a group /// </summary> /// <param name="group">The mix group.</param> /// <returns> /// A ListResponse containing Mixes or an Error /// </returns> public Task <ListResponse <Mix> > GetMixesAsync(MixGroup group) { return(this.GetMixesAsync(group, null)); }
public void HashCodeCanBeRetrievedWhenIdIsNull() { MixGroup mixGroup = new MixGroup(); Assert.IsNotNull(mixGroup.GetHashCode(), "Expected a hash code"); }