Exemple #1
0
        public static Album GenerateAlbum()
        {
            var tracksPerAlbum    = new Limit(8, 20);
            var wordsInAlbumTitle = new Limit(1, 3);
            var wordsInTrackTitle = new Limit(1, 6);

            var trackCount = tracksPerAlbum.RandomValue();
            var artistRng  = new Random();
            var artistName = ArtistNames[artistRng.Next(ArtistNames.Length)];

            var album = new Album
            {
                Artist = new Artist {
                    Name = artistName
                },
                Id       = Guid.NewGuid().ToString(),
                Title    = ToTitleCase(String.Join(" ", wordsInAlbumTitle.RandomSet(AlbumWords))),
                Tracks   = new List <Track>(),
                CoverUri = new Uri("https://placehold.it/256")
            };

            for (var i = 0; i < trackCount; i++)
            {
                album.Tracks.Add(new Track
                {
                    Album  = album,
                    Artist = new Artist {
                        Name = artistName
                    },
                    DiscNumber  = 1,
                    TrackNumber = i + 1,
                    Id          = Guid.NewGuid().ToString(),
                    Title       = ToTitleCase(String.Join(" ", wordsInTrackTitle.RandomSet(TrackWords)))
                });
            }

            return(album);
        }
Exemple #2
0
        public static string GenerateTitle()
        {
            var wordsInAlbumTitle = new Limit(rng, 1, 3);

            return(ToTitleCase(String.Join(" ", wordsInAlbumTitle.RandomSet(AlbumWords))));
        }