示例#1
0
        public void OpenFlacFileAndCreateMultipleApplicationInfo()
        {
            int    appInfoCount = 0;
            string origFile     = @"Data\testfile3.flac";
            string newFile      = @"Data\testfile3_temp.flac";

            FileHelper.GetNewFile(origFile, newFile);

            try
            {
                using (FlacFile flac = new FlacFile(newFile))
                {
                    if (flac.ApplicationInfo != null)
                    {
                        appInfoCount = 1;
                    }

                    ApplicationInfo appInfo = new ApplicationInfo();
                    appInfo.ApplicationID   = 10;
                    appInfo.ApplicationData = new byte[] { 10, 20, 30 };

                    flac.Metadata.Add(appInfo);

                    appInfo = new ApplicationInfo();
                    appInfo.ApplicationID   = 20;
                    appInfo.ApplicationData = new byte[] { 40, 50, 60 };

                    flac.Metadata.Add(appInfo);

                    appInfoCount += 2;

                    flac.Save();
                }
                using (FlacFile flac = new FlacFile(newFile))
                {
                    IEnumerable <ApplicationInfo> appInfo = flac.GetAllApplicationInfo();

                    Assert.AreEqual <int>(appInfoCount, appInfo.Count());

                    Assert.AreEqual <uint>(10, appInfo.ElementAt(appInfoCount - 2).ApplicationID);
                    Assert.AreEqual <uint>(20, appInfo.ElementAt(appInfoCount - 1).ApplicationID);
                }
            }
            finally
            {
                if (File.Exists(newFile))
                {
                    File.Delete(newFile);
                }
            }
        }
示例#2
0
        public void OpenFlacFileAndCreateMultipleApplicationInfo()
        {
            int appInfoCount = 0;
            string origFile = @"Data\testfile3.flac";
            string newFile = @"Data\testfile3_temp.flac";

            FileHelper.GetNewFile(origFile, newFile);

            try
            {
                using (FlacFile flac = new FlacFile(newFile))
                {
                    if (flac.ApplicationInfo != null)
                    {
                        appInfoCount = 1;
                    }

                    ApplicationInfo appInfo = new ApplicationInfo();
                    appInfo.ApplicationID = 10;
                    appInfo.ApplicationData = new byte[] { 10, 20, 30 };

                    flac.Metadata.Add(appInfo);

                    appInfo = new ApplicationInfo();
                    appInfo.ApplicationID = 20;
                    appInfo.ApplicationData = new byte[] { 40, 50, 60 };

                    flac.Metadata.Add(appInfo);

                    appInfoCount += 2;

                    flac.Save();
                }
                using (FlacFile flac = new FlacFile(newFile))
                {
                    IEnumerable<ApplicationInfo> appInfo = flac.GetAllApplicationInfo();

                    Assert.AreEqual<int>(appInfoCount, appInfo.Count());

                    Assert.AreEqual<uint>(10, appInfo.ElementAt(appInfoCount - 2).ApplicationID);
                    Assert.AreEqual<uint>(20, appInfo.ElementAt(appInfoCount - 1).ApplicationID);
                }
            }
            finally
            {
                if (File.Exists(newFile))
                {
                    File.Delete(newFile);
                }
            }
        }