public void ConvertTest1()
        {
            var playCounterFrame = new PlayCounterFrame();
            Assert.AreEqual(playCounterFrame.Descriptor.ID, "PCNT");
            Assert.AreEqual(playCounterFrame.Counter, 0);

            var rawFrame = playCounterFrame.Convert();
            Assert.AreEqual(rawFrame.ID, "PCNT");

            var payloadBytes = rawFrame.Payload;
            var refBytes = new byte[] {0x00, 0x00, 0x00, 0x00};

            Assert.IsTrue(ComparePayload(refBytes, payloadBytes));
        }
        public void ConvertTest4()
        {
            const long counterValue = 0x01FFFF;

            var playCounterFrame = new PlayCounterFrame(counterValue);
            Assert.AreEqual(playCounterFrame.Descriptor.ID, "PCNT");
            Assert.AreEqual(playCounterFrame.Counter, counterValue);

            var rawFrame = playCounterFrame.Convert();
            Assert.AreEqual(rawFrame.ID, "PCNT");

            var payloadBytes = rawFrame.Payload;
            var refBytes = new byte[] {0x00, 0x01, 0xFF, 0xFF};

            Assert.IsTrue(ComparePayload(refBytes, payloadBytes));
        }
Esempio n. 3
0
        public void SynchronizedTest5()
        {
            var tagContainer1 = new TagContainerV3();
            tagContainer1.Tag.SetHeaderFlags(true, false, false);

            const long counter = 0x12FF;
            var playCounter = new PlayCounterFrame(counter);
            tagContainer1.Add(playCounter);

            var tagContainer2 = WriteAndRead(tagContainer1);
            CompareContainer(tagContainer1, tagContainer2);

            var playCounter2 = FrameUtils.ConvertToPlayCounterFrame(tagContainer2[0]);
            Assert.AreEqual(playCounter2.Counter, counter);
        }
        public void ConvertTest8()
        {
            const long counterValue = 0x7FFFFFFFFFFFFFFF;

            // This must be a very very good song ;-)

            var playCounterFrame = new PlayCounterFrame(counterValue);
            Assert.AreEqual(playCounterFrame.Descriptor.ID, "PCNT");
            Assert.AreEqual(playCounterFrame.Counter, counterValue);

            var rawFrame = playCounterFrame.Convert();
            Assert.AreEqual(rawFrame.ID, "PCNT");

            var payloadBytes = rawFrame.Payload;
            var refBytes = new byte[] {0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

            Assert.IsTrue(ComparePayload(refBytes, payloadBytes));
        }
Esempio n. 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;
 }