コード例 #1
0
		public void ValidationOKTest()
		{
			/*
             *  T___
             *  TXXX
             *  WXXX
             *  APIC
             */

			var tagContainer = new TagContainerV3();
			tagContainer.Tag.SetExtendedHeader(0, false);
			tagContainer.Tag.SetHeaderFlags(false, false, false);

			var textFrame = new TextFrame("TALB", "My Albun", Encoding.Default);
			var userDefineTextFrame = new UserDefinedTextFrame("my comment", "so", Encoding.Default);
			var linkFrame = new UserDefinedURLLinkFrame("id3tag", "id3tag.codeplex.com", Encoding.Default);
			var pictureFrame = new PictureFrame(
				Encoding.Default,
				"image/jpeg",
				"la",
				PictureType.Other,
				new byte[] { 0x11, 0x12, 0x13, 0x14 });

			tagContainer.Add(textFrame);
			tagContainer.Add(userDefineTextFrame);
			tagContainer.Add(linkFrame);
			tagContainer.Add(pictureFrame);

			WriteTagContainer(tagContainer);

			// OK... passed!
		}
コード例 #2
0
        public void ConverterISO88591_Test()
        {
            var frame = new UserDefinedURLLinkFrame();

            frame.Description = "ABCD";
            frame.TextEncoding = TextEncodingType.ISO_8859_1;
            frame.URL = "EFGH";
            frame.Descriptor.ID = "WXXX";

            var refPayloadBytes = new byte[] {0x00, 0x41, 0x42, 0x43, 0x44, 0x00, 0x45, 0x46, 0x47, 0x48};
            var rawFrame = frame.Convert();
            Assert.AreEqual(rawFrame.ID, "WXXX");
            Assert.AreEqual(rawFrame.Payload, refPayloadBytes);
        }
コード例 #3
0
        public void ConverterUTF8_Test()
        {
            var frame = new UserDefinedURLLinkFrame();

            frame.Description = "ABCD";
            frame.TextEncoding = Encoding.UTF8;
            frame.URL = "EFGH";
            frame.Descriptor.ID = "WXXX";

            var refPayloadBytes = new byte[]
                                      {
                                          0x03,
                                          0x41, 0x42, 0x43, 0x44, 0x00,
                                          0x45, 0x46, 0x47, 0x48
                                      };
            var rawFrame = frame.Convert(TagVersion.Id3V23);
            Assert.AreEqual(rawFrame.ID, "WXXX");
            Assert.AreEqual(rawFrame.Payload, refPayloadBytes);
        }
コード例 #4
0
        public void CreateTest()
        {
            var frame = new UserDefinedURLLinkFrame("ABCD", "EFGH", TextEncodingType.UTF16);

            Assert.AreEqual(frame.Descriptor.ID, "WXXX");
            Assert.AreEqual(frame.Description, "ABCD");
            Assert.AreEqual(frame.URL, "EFGH");
            Assert.AreEqual(frame.TextEncoding, TextEncodingType.UTF16);
        }
コード例 #5
0
        public void ValidationPictureFrameFailed1()
        {
            /*
             *  T___
             *  TXXX
             *  WXXX
             *  APIC
             */

            var tagContainer = new TagContainer();
            tagContainer.Tag.SetExtendedHeader(0, false);
            tagContainer.Tag.SetHeaderFlags(false, false, false);
            tagContainer.Tag.SetVersion(3, 0);

            var textFrame = new TextFrame("TALB", "My Albun", TextEncodingType.ISO_8859_1);
            var userDefineTextFrame = new UserDefinedTextFrame("my comment", "so", TextEncodingType.ISO_8859_1);
            var linkFrame = new UserDefinedURLLinkFrame("id3tag", "id3tag.codeplex.com", TextEncodingType.ISO_8859_1);
            var pictureFrame = new PictureFrame(TextEncodingType.UTF16_BE, "image/jpeg", "la", PictureType.Other,
                                                new byte[] { 0x11, 0x12, 0x13, 0x14 });

            tagContainer.Add(textFrame);
            tagContainer.Add(userDefineTextFrame);
            tagContainer.Add(linkFrame);
            tagContainer.Add(pictureFrame);

            WriteTagContainer(tagContainer);

            // OK... passed!
        }
コード例 #6
0
        public void CreateTest()
        {
            var frame = new UserDefinedURLLinkFrame("ABCD", "EFGH", Encoding.Unicode);

            Assert.AreEqual(frame.Descriptor.ID, "WXXX");
            Assert.AreEqual(frame.Description, "ABCD");
            Assert.AreEqual(frame.URL, "EFGH");
            Assert.AreEqual(frame.TextEncoding.CodePage, Encoding.Unicode.CodePage);
        }
コード例 #7
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;
 }