Пример #1
0
 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;
 }
Пример #2
0
        public void FrameParsing()
        {
            var parser = new TagParser("<ar><ti>");
            var expect = new List<FrameType>()
            {
                FrameType.Artist,FrameType.Title
            };

            CollectionAssert.AreEquivalent(expect,parser.GetTags());
        }
Пример #3
0
        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]);
        }
Пример #4
0
        public void DublicateTagFrameParsing()
        {
            var parser = new TagParser("<ar><ar>");
            parser.GetTags();

            var expect = new List<FrameType>()
            {
                FrameType.Artist
            };

            CollectionAssert.AreEquivalent(expect, parser.GetTags());
        }
Пример #5
0
        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);
        }
Пример #6
0
        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;
        }
Пример #7
0
        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;
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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]);
        }
Пример #11
0
        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]);
        }
Пример #12
0
 public void NotExistingTagValueParsingException()
 {
     var parser = new TagParser("<a>");
     var frames = parser.GetTagsValue("msg");
 }
Пример #13
0
 public void NotCorrectPatternValueParsing()
 {
     var parser = new TagParser("<ar><al>");
     Assert.AreEqual(null, parser.GetTagsValue("msg"));
 }
Пример #14
0
 public void NotCompleteTagValueParsing()
 {
     var parser = new TagParser("<ar");
     parser.GetTagsValue("msg");
 }