public bool RetagFile(string pattern) { var parser = new TagParser(pattern); var parsedTags = parser.GetTagsValue(_fileHandler.FileName); if (parsedTags == null) return false; _fileHandler.SetTags(parsedTags); return true; }
public void FrameParsing() { var parser = new TagParser("<ar><ti>"); var expect = new List<FrameType>() { FrameType.Artist,FrameType.Title }; CollectionAssert.AreEquivalent(expect,parser.GetTags()); }
public void FakeEndOfTagValueParsing() { var artist = "arti -st"; var title = "title"; var expect = artist + " - " + title; var parser = new TagParser("<ar> - <ti>"); var frames = parser.GetTagsValue(expect); Assert.AreEqual(artist, frames[FrameType.Artist]); Assert.AreEqual(title, frames[FrameType.Title]); }
public void DublicateTagFrameParsing() { var parser = new TagParser("<ar><ar>"); parser.GetTags(); var expect = new List<FrameType>() { FrameType.Artist }; CollectionAssert.AreEquivalent(expect, parser.GetTags()); }
public bool RetagFile(string pattern) { var parser = new TagParser(pattern); var parsedTags = parser.GetTagsValue(_fileHandler.FileName); if (parsedTags == null) { return(false); } _fileHandler.SetTags(parsedTags); return(true); }
public bool Synchronize(string pattern) { var parser = new TagParser(pattern); var pathTagsValue = parser.GetTagsValue(_fileHandler.FileName); var requringTags = new SortedSet<FrameType>(parser.GetTags()); var fileTags = new SortedSet<FrameType>(_fileHandler.GetTags().Keys); var pathTagsIsBad = pathTagsValue == null; var fileTagsIsBad = !requringTags.IsSubsetOf(fileTags); if (pathTagsIsBad && !fileTagsIsBad) return RenameFile(pattern); if (!pathTagsIsBad && fileTagsIsBad) return RetagFile(pattern); return false; }
public Dictionary<FrameType, TagDifference> Difference(string pattern) { var parser = new TagParser(pattern); var pathTags = parser.GetTagsValue(_fileHandler.FileName); if (pathTags == null) return null; var fileTags = _fileHandler.GetTags(GetTagsOption.DontRemoveEmptyTags); var tagDifference = new Dictionary<FrameType,TagDifference>(); foreach (var pathTag in pathTags) { if (pathTag.Value != fileTags[pathTag.Key]) tagDifference.Add(pathTag.Key, new TagDifference(fileTags[pathTag.Key], pathTag.Value)); } return tagDifference.Count != 0 ? tagDifference : null; }
public bool Synchronize(string pattern) { var parser = new TagParser(pattern); var pathTagsValue = parser.GetTagsValue(_fileHandler.FileName); var requringTags = new SortedSet <FrameType>(parser.GetTags()); var fileTags = new SortedSet <FrameType>(_fileHandler.GetTags().Keys); var pathTagsIsBad = pathTagsValue == null; var fileTagsIsBad = !requringTags.IsSubsetOf(fileTags); if (pathTagsIsBad && !fileTagsIsBad) { return(RenameFile(pattern)); } if (!pathTagsIsBad && fileTagsIsBad) { return(RetagFile(pattern)); } return(false); }
public Dictionary <FrameType, TagDifference> Difference(string pattern) { var parser = new TagParser(pattern); var pathTags = parser.GetTagsValue(_fileHandler.FileName); if (pathTags == null) { return(null); } var fileTags = _fileHandler.GetTags(GetTagsOption.DontRemoveEmptyTags); var tagDifference = new Dictionary <FrameType, TagDifference>(); foreach (var pathTag in pathTags) { if (pathTag.Value != fileTags[pathTag.Key]) { tagDifference.Add(pathTag.Key, new TagDifference(fileTags[pathTag.Key], pathTag.Value)); } } return(tagDifference.Count != 0 ? tagDifference : null); }
public void TwoTagValueParsing() { var artist = "artist"; var title = "title"; // TODO :: this is not 'expect' - 'input' var expect = artist + " - " + title; var parser = new TagParser("<ar> - <ti>"); var frames = parser.GetTagsValue(expect); Assert.AreEqual(artist, frames[FrameType.Artist]); Assert.AreEqual(title, frames[FrameType.Title]); }
public void OneTagValueParsing() { var expect = "artist"; var parser = new TagParser("<ar>"); var frames = parser.GetTagsValue(expect); Assert.AreEqual(1, frames.Count); Assert.AreEqual(expect, frames[FrameType.Artist]); }
public void NotExistingTagValueParsingException() { var parser = new TagParser("<a>"); var frames = parser.GetTagsValue("msg"); }
public void NotCorrectPatternValueParsing() { var parser = new TagParser("<ar><al>"); Assert.AreEqual(null, parser.GetTagsValue("msg")); }
public void NotCompleteTagValueParsing() { var parser = new TagParser("<ar"); parser.GetTagsValue("msg"); }