Example #1
0
 public void TestOverrides()
 {
     Artist artist = new Artist() { Id = TestId, Name = TestName };
     Assert.IsNotNull(artist.GetHashCode(), "Expected a hash code");
     Assert.IsTrue(artist.Equals(new Artist() { Id = TestId }), "Expected equality");
     Assert.IsFalse(artist.Equals(TestId), "Expected inequality");
 }
Example #2
0
        public void TestProperties()
        {
            Artist artist = new Artist() { Id = TestId, Name = TestName };

            Assert.AreEqual(TestId, artist.Id, "Expected the property to persist");
            Assert.AreEqual(TestName, artist.Name, "Expected the property to persist");
        }
Example #3
0
        public void EnsureIListPropertiesWorkForErrorCase()
        {
            ListResponse<Artist> response = new ListResponse<Artist>(HttpStatusCode.NotFound, new ApiCallFailedException(), null, Guid.Empty);

            Artist artist = new Artist() { Id = "1234", Name = "Artist" };

            Assert.AreEqual(0, response.Count, "Expected an empty list");
            Assert.AreEqual(false, response.IsReadOnly, "Expected a readonly list");
            Assert.IsNull(response[0], "Expected an empty list");
            Assert.AreEqual(-1, response.IndexOf(artist), "Expected an empty list");
            Assert.IsFalse(response.Contains(artist), "Expected an empty list");

            // Check adding cases...
            response[0] = artist;
            Assert.AreEqual(0, response.Count, "Expected an empty list");
            response.Add(artist);
            Assert.AreEqual(0, response.Count, "Expected an empty list");
            response.Insert(0, artist);
            Assert.AreEqual(0, response.Count, "Expected an empty list");

            // Check CopyTo does nothing...
            Artist[] artists = new Artist[0];
            response.CopyTo(artists, 0);
            Assert.AreEqual(0, artists.Length, "Expected an empty list");

            // Check remove cases...
            response.Remove(artist);
            Assert.AreEqual(0, response.Count, "Expected an empty list");
            response.RemoveAt(0);
            Assert.AreEqual(0, response.Count, "Expected an empty list");
            response.Clear();
            Assert.AreEqual(0, response.Count, "Expected an empty list");
        }
Example #4
0
        public void EnsureIListPropertiesWorkForSuccessCase()
        {
            List<Artist> artists = new List<Artist>()
            {
                new Artist() { Id = "1234", Name = "Artist" },
                new Artist() { Id = "12345", Name = "Artist" },
                new Artist() { Id = "123456", Name = "Artist" }
            };

            ListResponse<Artist> response = new ListResponse<Artist>(HttpStatusCode.OK, artists, 0, 10, 3, Guid.Empty);

            Assert.AreEqual(3, response.Count, "Expected a list");
            Assert.AreEqual(false, response.IsReadOnly, "Expected a readonly list");
            Assert.AreEqual(false, response.IsFixedSize, "Expected a non fixed size list");
            Assert.AreEqual(false, response.IsSynchronized, "Expected a non sync list");
            Assert.IsNotNull(response.SyncRoot, "Expected an object");
            Assert.AreEqual(artists[0], response[0], "Expected the same item");
            Assert.AreEqual(artists[0], (response as IList)[0], "Expected the same item");
            Assert.AreEqual(1, response.IndexOf(artists[1]), "Expected the same item");
            Assert.AreEqual(1, (response as IList).IndexOf(artists[1]), "Expected the same item");
            Assert.IsTrue(response.Contains(artists[1]), "Expected the item in there");
            Assert.IsTrue((response as IList).Contains(artists[1]), "Expected the item in there");

            // Check adding cases...
            response[2] = new Artist();
            Assert.AreEqual(3, response.Count, "Expected same items");
            (response as IList)[1] = new Artist();
            Assert.AreEqual(3, response.Count, "Expected same items");
            response.Add(new Artist());
            Assert.AreEqual(4, response.Count, "Expected more items");
            (response as IList).Add(new Artist());
            Assert.AreEqual(5, response.Count, "Expected more items");
            response.Insert(1, new Artist());
            Assert.AreEqual(6, response.Count, "Expected more items");
            (response as IList).Insert(1, new Artist());
            Assert.AreEqual(7, response.Count, "Expected more items");

            // Check CopyTo...
            Artist[] newArtists = new Artist[response.Count];
            response.CopyTo(newArtists, 0);
            Assert.AreEqual(response.Count, newArtists.Length, "Expected the same number");
            (response as IList).CopyTo(newArtists, 0);
            Assert.AreEqual(response.Count, newArtists.Length, "Expected the same number");

            // Check remove cases...
            response.Remove(artists[0]);
            Assert.AreEqual(6, response.Count, "Expected less items");
            (response as IList).Remove(artists[0]);
            Assert.AreEqual(5, response.Count, "Expected less items");
            response.RemoveAt(0);
            Assert.AreEqual(4, response.Count, "Expected less items");
            response.Clear();
            Assert.AreEqual(0, response.Count, "Expected an empty list");
        }
Example #5
0
 /// <summary>
 /// Shows the Artist Page in MixRadio
 /// </summary>
 /// <returns>An async task to await</returns>
 public async Task Show()
 {
     if (string.IsNullOrEmpty(this._artistId) && string.IsNullOrEmpty(this._artistName))
     {
         throw new InvalidOperationException("Please set an artist ID or name before calling Show()");
     }
     else
     {
         var artist = new Artist { Id = this._artistId, Name = this._artistName };
         await this.Launch(artist.AppToAppUri, artist.WebUri).ConfigureAwait(false);
     }
 }
Example #6
0
        /// <summary>
        /// Shows the Search Page in MixRadio
        /// </summary>
        /// <returns>An async task to await</returns>
        public async Task Show()
        {
            if (!string.IsNullOrEmpty(this._searchTerms))
            {
#if WINDOWS_APP
                var appUri = new Uri("nokia-music://search/anything/?term=" + this._searchTerms);
#else
                var appUri = new Uri("mixradio://search/anything/" + this._searchTerms);
#endif
                // Fall back to artist mix on web
                var artist = new Artist { Name = this._searchTerms.Replace("&", string.Empty) };
                await this.Launch(appUri, artist.WebUri).ConfigureAwait(false);
            }
            else
            {
                throw new InvalidOperationException("Please set the search term before calling Show()");
            }
        }
Example #7
0
        public void TestLinkingProperties()
        {
            var itemWithId = new Artist() { Id = TestId };
            var itemWithName = new Artist() { Name = TestName };
            var itemWithNullProperties = new Artist();

            Assert.IsNotNull(itemWithId.AppToAppUri, "Expected App to App URI to be calculated");
            Assert.IsNotNull(itemWithName.AppToAppUri, "Expected App to App URI to be calculated");
            Assert.IsNull(itemWithNullProperties.AppToAppUri, "Expected App to App URI not to be calculated");

            Assert.IsNotNull(itemWithId.AppToAppPlayUri, "Expected App to App URI to be calculated");
            Assert.IsNotNull(itemWithName.AppToAppPlayUri, "Expected App to App Play URI to be calculated");
            Assert.IsNull(itemWithNullProperties.AppToAppPlayUri, "Expected App to App Play URI not to be calculated");

            Assert.IsNotNull(itemWithId.WebUri, "Expected Web URI to be calculated");
            Assert.IsNull(itemWithNullProperties.WebUri, "Expected Web URI not to be calculated");

            Assert.IsNotNull(itemWithName.WebUri, "Expected Web Play URI to be calculated");
            Assert.IsNull(itemWithNullProperties.WebUri, "Expected Web Play URI not to be calculated");
        }
Example #8
0
 public void HashCodeCanBeRetrievedWhenIdIsNull()
 {
     Artist artist = new Artist();
     Assert.IsNotNull(artist.GetHashCode(), "Expected a hash code");
 }
Example #9
0
 /// <summary>
 /// Plays the Mix in MixRadio
 /// </summary>
 /// <returns>An async task to await</returns>
 public async Task Show()
 {
     if (!string.IsNullOrEmpty(this.MixId))
     {
         var mix = new Mix { Id = this.MixId };
         await this.Launch(mix.AppToAppUri, mix.WebUri).ConfigureAwait(false);
     }
     else if (!string.IsNullOrEmpty(this._artistId))
     {
         var artist = new Artist { Id = this._artistId };
         await this.Launch(artist.AppToAppPlayUri, artist.WebUri).ConfigureAwait(false);
     }
     else if (!string.IsNullOrEmpty(this._artistName))
     {
         var artist = new Artist { Name = this._artistName };
         await this.Launch(artist.AppToAppPlayUri, artist.WebUri).ConfigureAwait(false);
     }
     else
     {
         throw new InvalidOperationException("Please set a mix ID, artist id or artist name before calling Show()");
     }
 }