using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;

namespace m3uTool.Tests
{
    /// <summary>
    /// Summary description for MP3HeaderTests.
    /// </summary>
    public class Mp3FilePropertiesTests
    {
        public void Mp3FileDetailsTest()
        {
            string[] files = Directory.GetFiles(".", "*.mp3");
            var properties = new List<Mp3FileProperties>();
            foreach (string mp3Filename in files)
            {
                Debug.WriteLine(mp3Filename);
                Debug.Indent();

                // bool boolIsMP3 = mp3hdr.ReadMP3Information(mp3Filename);
                var fileDetails = new Mp3FileProperties(mp3Filename);
                properties.Add(fileDetails);
                if (fileDetails != null)
                {
                    Debug.WriteLine(GetMp3FilePropertyReport(fileDetails));
                }
                Debug.Unindent();
            }
            Mp3FileProperties commonProperties = Mp3FileProperties.GetCommonProperties(properties);
            Debug.WriteLine(GetMp3FilePropertyReport(commonProperties));
        }

        private static string GetMp3FilePropertyReport(Mp3FileProperties fileDetails)
        {
            var report = new StringBuilder();
            report.AppendLine("Filename:    " + fileDetails.Mp3PathAndFilename);
            report.AppendLine("mFileSize: " + fileDetails.FileSize);
            report.AppendLine("mBitRate:  " + fileDetails.BitRate);
            report.AppendLine("mSampleRateIntegerFrequency:" + fileDetails.SampleRateIntegerFrequency);
            report.AppendLine("strMode:     " + fileDetails.ChannelMode);
            report.AppendLine("strLengthFo: " + fileDetails.LengthFormatted);
            report.AppendLine("mLengthInSeconds:   " + fileDetails.LengthInSeconds);

            report.AppendLine("title:       " + fileDetails.Id3Title);
            report.AppendLine("artist:      " + fileDetails.Id3Artist);
            report.AppendLine("album:       " + fileDetails.Id3Album);
            report.AppendLine("track#:      " + fileDetails.Id3TrackNumber);
            report.AppendLine("genre:       " + fileDetails.Id3GenreName);
            return report.ToString();
        }
    }
}