public void CreateTest()
        {
            var popFrame = new PopularimeterFrame();

            Assert.AreEqual(popFrame.Descriptor.ID, "POPM");
            Assert.IsNotNull(popFrame.eMail);
            Assert.AreEqual(popFrame.PlayCounter, 0);
            Assert.AreEqual(popFrame.Rating, 0);
        }
        public void ConvertTest4()
        {
            var popFrame = new PopularimeterFrame("ABC", 0xF, 0x7FFFFFFF);

            var rawFrame = popFrame.Convert();

            Assert.AreEqual(rawFrame.ID, "POPM");
            var payload = rawFrame.Payload;
            var refBytes = new byte[] {0x41, 0x42, 0x43, 0x00, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF};

            Assert.IsTrue(ComparePayload(refBytes, payload));
        }
        public void CreateTest2()
        {
            const string mail = "Mail";
            const int playCounter = 3;
            const int rating = 0xFF;

            var popFrame = new PopularimeterFrame(mail, rating, playCounter);

            Assert.AreEqual(popFrame.Descriptor.ID, "POPM");
            Assert.AreEqual(popFrame.eMail, mail);
            Assert.AreEqual(popFrame.PlayCounter, playCounter);
            Assert.AreEqual(popFrame.Rating, rating);
        }
        public void CreateTest3()
        {
            var popFrame = new PopularimeterFrame("", 0xF, 0x7FFFFFFF);

            var rawFrame = popFrame.Convert(TagVersion.Id3V23);

            Assert.AreEqual(rawFrame.ID, "POPM");
            var payload = rawFrame.Payload;
            var refBytes = new byte[] {0x00, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF};

            Assert.IsTrue(ComparePayload(refBytes, payload));
        }
Пример #5
0
 private static IFrame AnalyseFrameId(RawFrame rawFrame)
 {
     IFrame frame;
     if (rawFrame.ID[0] == 'T' || rawFrame.ID[0] == 'W')
     {
         switch (rawFrame.ID[0])
         {
             case 'T':
                 if (rawFrame.ID != "TXXX")
                 {
                     frame = new TextFrame();
                 }
                 else
                 {
                     frame = new UserDefinedTextFrame();
                 }
                 break;
             case 'W':
                 if (rawFrame.ID != "WXXX")
                 {
                     frame = new UrlLinkFrame();
                 }
                 else
                 {
                     frame = new UserDefinedURLLinkFrame();
                 }
                 break;
             default:
                 throw new ID3TagException("Unknown Text or URL frame!");
         }
     }
     else
     {
         // Other frames
         switch (rawFrame.ID)
         {
             case "AENC":
                 frame = new AudioEncryptionFrame();
                 break;
             case "PRIV":
                 frame = new PrivateFrame();
                 break;
             case "MCDI":
                 frame = new MusicCdIdentifierFrame();
                 break;
             case "COMM":
                 frame = new CommentFrame();
                 break;
             case "APIC":
                 frame = new PictureFrame();
                 break;
             case "PCNT":
                 frame = new PlayCounterFrame();
                 break;
             case "POPM":
                 frame = new PopularimeterFrame();
                 break;
             case "UFID":
                 frame = new UniqueFileIdentifierFrame();
                 break;
             default:
                 frame = new UnknownFrame();
                 break;
         }
     }
     return frame;
 }