public void CreateTest2()
 {
     var frame = new AudioEncryptionFrame();
     Assert.AreEqual(frame.Descriptor.ID, "AENC");
     Assert.IsNotNull(frame.Owner);
     Assert.IsNotNull(frame.Encryption);
 }
        public void CreateTest()
        {
            var bytes = new byte[] {0x20, 0x21, 0x22};
            var frame = new AudioEncryptionFrame("ABCD", 0, 0xFF, bytes);

            Assert.AreEqual(frame.Descriptor.ID, "AENC");
            Assert.AreEqual(frame.Owner, "ABCD");
            Assert.AreEqual(frame.PreviewStart, 0);
            Assert.AreEqual(frame.PreviewLength, 0xFF);
            Assert.IsTrue(ComparePayload(bytes, frame.Encryption));
        }
        public void ConvertTest()
        {
            var bytes = new byte[] {0x20, 0x21, 0x22};
            var frame = new AudioEncryptionFrame("ABCD", 0x00FF, 0xFF00, bytes);

            Assert.AreEqual(frame.Descriptor.ID, "AENC");
            Assert.AreEqual(frame.Owner, "ABCD");
            Assert.AreEqual(frame.PreviewStart, 0x00FF);
            Assert.AreEqual(frame.PreviewLength, 0xFF00);
            Assert.IsTrue(ComparePayload(bytes, frame.Encryption));

            var refBytes = new byte[]
                               {
                                   0x41, 0x42, 0x43, 0x44, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x20, 0x21, 0x22
                               };

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

            Assert.AreEqual(rawFrame.ID, "AENC");
            Assert.IsTrue(ComparePayload(rawFrame.Payload, refBytes));
        }
Exemplo n.º 4
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;
 }