public virtual void TestShouldConvertFrameDataWithBlankDescriptionAndLanguageToBytesAndBackToEquivalentObject() { byte[] bytes = new byte[] { 0, 0, 0, 0, 0, (byte)('A'), (byte)('B'), (byte)('C'), (byte)('D'), (byte)('E'), (byte)('F'), (byte)('G'), (byte)('H'), (byte)('I'), (byte )('J'), (byte)('K'), (byte)('L'), (byte)('M'), (byte)('N'), (byte)('O'), (byte)( 'P'), (byte)('Q') }; ID3v2CommentFrameData frameData = new ID3v2CommentFrameData(false, bytes); Assert.AreEqual("\x0\x0\x0", frameData.GetLanguage()); Assert.AreEqual(new EncodedText(string.Empty), frameData.GetDescription()); Assert.AreEqual(new EncodedText(TEST_VALUE), frameData.GetComment()); Assert.IsTrue(Arrays.Equals(bytes, frameData.ToBytes())); }
public virtual void TestShouldConvertFrameDataToBytesAndBackToEquivalentObject() { ID3v2CommentFrameData frameData = new ID3v2CommentFrameData(false, TEST_LANGUAGE, new EncodedText(unchecked((byte)0), TEST_DESCRIPTION), new EncodedText(unchecked((byte)0), TEST_VALUE)); byte[] bytes = frameData.ToBytes(); byte[] expectedBytes = new byte[] { 0, (byte)('e'), (byte)('n'), (byte)('g'), (byte )('D'), (byte)('E'), (byte)('S'), (byte)('C'), (byte)('R'), (byte)('I'), (byte)( 'P'), (byte)('T'), (byte)('I'), (byte)('O'), (byte)('N'), 0, (byte)('A'), (byte) ('B'), (byte)('C'), (byte)('D'), (byte)('E'), (byte)('F'), (byte)('G'), (byte)('H' ), (byte)('I'), (byte)('J'), (byte)('K'), (byte)('L'), (byte)('M'), (byte)('N'), (byte)('O'), (byte)('P'), (byte)('Q') }; Assert.IsTrue(Arrays.Equals(expectedBytes, bytes)); ID3v2CommentFrameData frameDataCopy = new ID3v2CommentFrameData(false, bytes); Assert.AreEqual(frameData, frameDataCopy); }
public virtual void TestShouldConvertFrameDataWithUnicodeToBytesAndBackToEquivalentObject() { ID3v2CommentFrameData frameData = new ID3v2CommentFrameData(false, TEST_LANGUAGE, new EncodedText(EncodedText.TEXT_ENCODING_UTF_16, TEST_DESCRIPTION_UNICODE), new EncodedText(EncodedText.TEXT_ENCODING_UTF_16, TEST_VALUE_UNICODE)); byte[] bytes = frameData.ToBytes(); byte[] expectedBytes = new byte[] { 1, (byte)('e'), (byte)('n'), (byte)('g'), unchecked( (byte)unchecked((int)(0xff))), unchecked((byte)unchecked((int)(0xfe))), unchecked( (byte)unchecked((int)(0xb3))), unchecked((int)(0x03)), unchecked((byte)unchecked( (int)(0xb5))), unchecked((int)(0x03)), unchecked((byte)unchecked((int)(0xb9))), unchecked((int)(0x03)), unchecked((byte)unchecked((int)(0xac))), unchecked((int) (0x03)), 0, 0, unchecked((byte)unchecked((int)(0xff))), unchecked((byte)unchecked( (int)(0xfe))), unchecked((byte)unchecked((int)(0xc3))), unchecked((int)(0x03)), unchecked((byte)unchecked((int)(0xbf))), unchecked((int)(0x03)), unchecked((byte )unchecked((int)(0xc5))), unchecked((int)(0x03)) }; Assert.IsTrue(Arrays.Equals(expectedBytes, bytes)); ID3v2CommentFrameData frameDataCopy = new ID3v2CommentFrameData(false, bytes); Assert.AreEqual(frameData, frameDataCopy); }
public virtual void TestShouldConsiderTwoEquivalentObjectsEqual() { ID3v2CommentFrameData frameData1 = new ID3v2CommentFrameData(false, TEST_LANGUAGE, new EncodedText(unchecked((byte)0), TEST_DESCRIPTION), new EncodedText(unchecked((byte)0), TEST_VALUE)); ID3v2CommentFrameData frameData2 = new ID3v2CommentFrameData(false, TEST_LANGUAGE, new EncodedText(unchecked((byte)0), TEST_DESCRIPTION), new EncodedText(unchecked((byte)0), TEST_VALUE)); Assert.AreEqual(frameData1, frameData2); }
public virtual void SetItunesComment(string itunesComment) { if (itunesComment != null && itunesComment.Length > 0) { InvalidateDataLength(); ID3v2CommentFrameData frameData = new ID3v2CommentFrameData(UseFrameUnsynchronisation (), ITUNES_COMMENT_DESCRIPTION, null, new EncodedText(itunesComment)); AddFrame(CreateFrame(ID_COMMENT, frameData.ToBytes()), true); } }
public virtual void SetComment(string comment) { if (comment != null && comment.Length > 0) { InvalidateDataLength(); ID3v2CommentFrameData frameData = new ID3v2CommentFrameData(UseFrameUnsynchronisation (), "eng", null, new EncodedText(comment)); AddFrame(CreateFrame(ID_COMMENT, frameData.ToBytes()), true); } }
private ID3v2CommentFrameData ExtractCommentFrameData(string id, bool itunes) { ID3v2FrameSet frameSet = frameSets.Get(id); if (frameSet != null) { Iterator<ID3v2Frame> iterator = frameSet.GetFrames().Iterator(); while (iterator.HasNext()) { ID3v2Frame frame = (ID3v2Frame)iterator.Next(); ID3v2CommentFrameData frameData; try { frameData = new ID3v2CommentFrameData(UseFrameUnsynchronisation(), frame.GetData( )); if (itunes && ITUNES_COMMENT_DESCRIPTION.Equals(frameData.GetDescription().ToString ())) { return frameData; } else { if (!itunes) { return frameData; } } } catch (InvalidDataException) { } } } // Do nothing return null; }