Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // work out a batch strategy
            const int batchNumber = 100;

            // get list of songs
            string pathToItunesLibrary = ConfigSettings.PathToXml;

            IEnumerable<Song> songs = new LibraryBuilder<Song>().BuildLibrary(pathToItunesLibrary);

            int counter = 0;
            int numberOfSongs = songs.Count();
            int numberOfBatches = numberOfSongs/batchNumber;

            // for each batch
            for(int i=0; i< numberOfBatches; i++)
            {
                int start = counter;
                // get list of songs
                IEnumerable<Song> songBatch = songs.Skip(start).Take(batchNumber);
                // add batch to Solr
                Console.WriteLine("Adding {0} through to{1}", start, start + batchNumber);

                counter += batchNumber;
            }

            Console.Read();
        }
        public void Should_return_list_of_type_song()
        {
            string pathToItunesLibrary = ConfigSettings.PathToXml;

            IEnumerable<Song> songs = new LibraryBuilder<Song>().BuildLibrary(pathToItunesLibrary);

            Assert.IsNotNull(songs);
            int count = songs.Count();
            Assert.Greater(count, 0);

            var song = songs.First();

            Assert.IsNotNull(song);

            Assert.IsInstanceOfType(typeof(Song), song);
        }