Пример #1
0
        public void TagList()
        {
            var sf = new SessionFile();

            sf.Tags = "classical; rock; ; jazz";
            Assert.AreEqual(3, sf.TagList.Count);
            Assert.AreEqual("classical", sf.TagList[0]);
            Assert.AreEqual("rock", sf.TagList[1]);
            Assert.AreEqual("jazz", sf.TagList[2]);
        }
Пример #2
0
        public void GetContextMenuItems_OddBallFile_GetJustTwoMenus()
        {
            var sf = new SessionFile();

            using (var f = new TempFile())
            {
                sf.FullFilePath = f.Path;
                Assert.AreEqual(2, sf.GetContextMenuItems("x").Count());
            }
        }
Пример #3
0
        public void GetContextMenuItems_AudioFile_GetSeveralRenamingMenus()
        {
            var sf = new SessionFile();

            using (var f = new TemporaryFolder("spongeTests"))
            {
                string path = f.Combine("foo.wav");                //TODO: extract to TempWaveFile
                File.CreateText(path).Close();
                sf.FullFilePath = path;
                Assert.IsTrue(sf.GetContextMenuItems("x").Count() > 4);
            }
        }
Пример #4
0
        public void IdentifyComponent_ShouldBeOk_Renames()
        {
            var sf = new SessionFile();

            using (var f = new TemporaryFolder("spongeTests"))
            {
                string path = f.Combine("foo.wav");
                File.CreateText(path).Close();
                sf.FullFilePath = path;
                //couldn't use the menu directly from test code:  sf.GetContextMenuItems("x").ToArray()[3].Select();

                sf.IdentifyAsComponent(SessionComponentDefinition.CreateHardCodedDefinitions().First(), "x");
                Assert.AreEqual("x_Original.wav", sf.FileName);
            }
        }
Пример #5
0
        /// ------------------------------------------------------------------------
        /// <summary>
        /// Returns the duration of the first session file matching the specified
        /// filter.
        /// </summary>
        /// ------------------------------------------------------------------------
        public TimeSpan GetDurationOfMatchingFile(Func <string, bool> filter)
        {
            foreach (var path in Files)
            {
                if (filter(path))
                {
                    TimeSpan duration;
                    if (!_sessionFileDurations.TryGetValue(path, out duration))
                    {
                        using (var sessionFile = SessionFile.Create(path))
                            _sessionFileDurations[path] = sessionFile.Duration;
                    }

                    return(_sessionFileDurations[path]);
                }
            }

            return(new TimeSpan());
        }