public void GetFileIsElligible_PathDoesNotMatch_False() { SessionComponentDefinition def = GetDefinitionForOriginalRecording(); Assert.IsFalse(def.GetFileIsElligible("fub.xmp3")); Assert.IsFalse(def.GetFileIsElligible("fub.mp3x")); }
public IEnumerable <ToolStripItem> GetContextMenuItems(string sessionId) { //enhance: move these two ones up to the base class yield return(new ToolStripMenuItem("Show file in Windows Explorer...", null, HandleOpenInFileManager_Click)); yield return(new ToolStripMenuItem("Open in Program Associated with this File ...", null, HandleOpenInApp_Click)); bool needSeparator = true; foreach (var definition in SessionComponentDefinition.CreateHardCodedDefinitions()) { if (definition.GetFileIsElligible(FullFilePath)) { if (needSeparator) { needSeparator = false; yield return(new ToolStripSeparator()); } string label = string.Format("Rename For {0}", definition.Name); SessionComponentDefinition componentDefinition = definition; yield return(new ToolStripMenuItem(label, null, (sender, args) => IdentifyAsComponent(componentDefinition, sessionId))); } } }
public void GetFileIsElligible_PathMatches_True() { SessionComponentDefinition def = GetDefinitionForOriginalRecording(); Assert.IsTrue(def.GetFileIsElligible("fub.wav")); Assert.IsTrue(def.GetFileIsElligible("fub.mp3")); Assert.IsTrue(def.GetFileIsElligible("fub.ogg")); Assert.IsTrue(def.GetFileIsElligible("fub.avi")); Assert.IsTrue(def.GetFileIsElligible("fub.mov")); }
public void IdentifyAsComponent(SessionComponentDefinition definition, string sessionId) { string newPath = definition.GetCanoncialName(sessionId, FullFilePath); try { File.Move(FullFilePath, newPath); FullFilePath = newPath; } catch (Exception e) { ErrorReport.ReportNonFatalException(e); } }
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); } }
public void SessionHasThisComponent_NonMatchingTemplate_False() { SessionComponentDefinition def = GetDefinitionForOriginalRecording(); Assert.IsFalse(def.SessionHasThisComponent("mySession", new string[] { @"c:\foo\mySession_BLAH.wav" })); }
public void SessionHasThisComponent_HaveOneMatching_True() { SessionComponentDefinition def = GetDefinitionForOriginalRecording(); Assert.IsTrue(def.SessionHasThisComponent("mySession", new string[] { "x.txt", @"c:\foo\mySession_Original.wav", "z.doc" })); }
public void GetCanonicalName_HasDirectoryInPath_ChangesName() { SessionComponentDefinition def = GetDefinitionForOriginalRecording(); Assert.AreEqual(@"c:\foo\mySession_Original.wav", def.GetCanoncialName("mySession", @"c:\foo\fub.wav")); }
private SessionComponentDefinition GetDefinitionForOriginalRecording() { return(SessionComponentDefinition.CreateHardCodedDefinitions().First()); }