Exemplo n.º 1
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");
        }
Exemplo n.º 2
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");
 }
Exemplo n.º 3
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.IsNull(itemWithNullProperties.AppToAppUri, "Expected App to App URI not 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.WebPlayUri, "Expected Web Play URI to be calculated");
            Assert.IsNull(itemWithNullProperties.WebPlayUri, "Expected Web Play URI not to be calculated");
        }
Exemplo n.º 4
0
 public void HashCodeCanBeRetrievedWhenIdIsNull()
 {
     Artist artist = new Artist();
     Assert.IsNotNull(artist.GetHashCode(), "Expected a hash code");
 }
Exemplo n.º 5
0
 public void TestShowGoesAheadWhenItCan()
 {
     Artist artist = new Artist() { Id = TestId };
     artist.Show();
     Assert.Pass();
 }
Exemplo n.º 6
0
 public void TestAristNamePropertyIsRequiredForShow()
 {
     Artist artist = new Artist();
     artist.Show();
 }
Exemplo n.º 7
0
 public void TestPlayMixGoesAheadWhenItCan()
 {
     Artist artist = new Artist() { Name = TestName };
     artist.PlayMix();
     Assert.Pass();
 }
Exemplo n.º 8
0
 public void TestAristNamePropertyIsRequiredForPlayMix()
 {
     Artist artist = new Artist();
     artist.PlayMix();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a Product from a JSON Object
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>A Product object</returns>
        internal static Product FromJToken(JToken item)
        {
            if (item == null)
            {
                return(null);
            }

            // Extract category...
            Category category     = Category.Unknown;
            JToken   jsonCategory = item["category"];

            if (jsonCategory != null)
            {
                category = ParseHelper.ParseEnumOrDefault <Category>(jsonCategory.Value <string>("id"));
            }

            // Extract genres...
            Genre[] genres     = null;
            JArray  jsonGenres = item.Value <JArray>("genres");

            if (jsonGenres != null)
            {
                List <Genre> list = new List <Genre>();
                foreach (JToken jsonGenre in jsonGenres)
                {
                    list.Add((Genre)Genre.FromJToken(jsonGenre));
                }

                genres = list.ToArray();
            }

            // Extract takenfrom...
            Product takenFrom     = null;
            JToken  jsonTakenFrom = item["takenfrom"];

            if (jsonTakenFrom != null)
            {
                takenFrom = (Product)FromJToken(jsonTakenFrom);
            }

            // Extract price...
            Price  price      = null;
            JToken jsonPrices = item["prices"];

            if (jsonPrices != null)
            {
                JToken jsonPermDownload = jsonPrices["permanentdownload"];
                if (jsonPermDownload != null)
                {
                    price = Price.FromJToken(jsonPermDownload);
                }
            }

            // Extract Artists...
            Artist[] performers = null;

            if (item["creators"] != null)
            {
                JArray jsonArtists = item["creators"].Value <JArray>("performers");
                if (jsonArtists != null)
                {
                    List <Artist> list = new List <Artist>();
                    foreach (JToken jsonArtist in jsonArtists)
                    {
                        list.Add((Artist)Artist.FromJToken(jsonArtist));
                    }

                    performers = list.ToArray();
                }
            }

            // Extract trackcount...
            int?   trackCount     = null;
            JToken jsonTrackCount = item["trackcount"];

            if (jsonTrackCount != null)
            {
                trackCount = item.Value <int>("trackcount");
            }

            // Extract thumbnails...
            Uri square50  = null;
            Uri square100 = null;
            Uri square200 = null;
            Uri square320 = null;

            MusicItem.ExtractThumbs(item["thumbnails"], out square50, out square100, out square200, out square320);

            // Create the resulting Product object...
            var product = new Product()
            {
                Id                = item.Value <string>("id"),
                Name              = item.Value <string>("name"),
                Thumb50Uri        = square50,
                Thumb100Uri       = square100,
                Thumb200Uri       = square200,
                Thumb320Uri       = square320,
                Category          = category,
                Genres            = genres,
                TakenFrom         = takenFrom,
                Price             = price,
                TrackCount        = trackCount,
                Tracks            = ExtractTracks(item["tracks"]),
                Performers        = performers,
                Duration          = item.Value <int>("duration"),
                VariousArtists    = item.Value <bool>("variousartists"),
                StreetReleaseDate = item.Value <DateTime>("streetreleasedate"),
                SellerStatement   = item.Value <string>("sellerstatement"),
                Label             = item.Value <string>("label")
            };

            var sequence = item.Value <int>("sequence");

            if (sequence >= 1)
            {
                product.Sequence = sequence;
            }

            return(product);
        }
Exemplo n.º 10
0
        public void TestLinkingProperties()
        {
            var item = new Artist() { Id = TestId };
            var itemWithNullId = new Artist();

            Assert.IsNotNull(item.AppToAppUri, "Expected App to App URI to be calculated");
            Assert.IsNull(itemWithNullId.AppToAppUri, "Expected App to App URI not to be calculated");
        }