File: DivXTest.cs

package info (click to toggle)
taglib-sharp 2.0.3.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,120 kB
  • ctags: 3,330
  • sloc: cs: 26,081; sh: 3,439; makefile: 283
file content (213 lines) | stat: -rw-r--r-- 6,656 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
using System;
using System.Security.Cryptography;
using NUnit.Framework;
using TagLib;

namespace TagLib.Tests.TaggingFormats
{
	[TestFixture]
	public class DivXTest
	{   
		[Test]
		public void TestTitle ()
		{
			Riff.DivXTag tag = new Riff.DivXTag ();

			Assert.IsTrue (tag.IsEmpty, "Initially empty");
			Assert.IsNull (tag.Title, "Initially null");

			ByteVector rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.IsNull (tag.Title, "Still null");

			tag.Title = "01234567890123456789012345678901234567890123456789";
			Assert.IsFalse (tag.IsEmpty, "Not empty");
			Assert.AreEqual ("01234567890123456789012345678901234567890123456789", tag.Title);

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsFalse (tag.IsEmpty, "Still not empty");
			Assert.AreEqual ("01234567890123456789012345678901", tag.Title);

			tag.Title = string.Empty;
			Assert.IsTrue (tag.IsEmpty, "Again empty");
			Assert.IsNull (tag.Title, "Again null");

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.IsNull (tag.Title, "Still null");
		}

		[Test]
		public void TestPerformers ()
		{
			Riff.DivXTag tag = new Riff.DivXTag ();

			Assert.IsTrue (tag.IsEmpty, "Initially empty");
			Assert.AreEqual (0, tag.Performers.Length, "Initially empty");

			ByteVector rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.AreEqual (0, tag.Performers.Length, "Still empty");

			tag.Performers = new string [] {"A123456789", "B123456789", "C123456789", "D123456789", "E123456789"};
			Assert.IsFalse (tag.IsEmpty, "Not empty");
			Assert.AreEqual ("A123456789; B123456789; C123456789; D123456789; E123456789", tag.JoinedPerformers);

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsFalse (tag.IsEmpty, "Still not empty");
			Assert.AreEqual ("A123456789; B123456789; C12345", tag.JoinedPerformers);

			tag.Performers = new string [0];
			Assert.IsTrue (tag.IsEmpty, "Again empty");
			Assert.AreEqual (0, tag.Performers.Length, "Again empty");

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.AreEqual (0, tag.Performers.Length, "Still empty");
		}

		[Test]
		public void TestYear ()
		{
			Riff.DivXTag tag = new Riff.DivXTag ();

			Assert.IsTrue (tag.IsEmpty, "Initially empty");
			Assert.AreEqual (0, tag.Year, "Initially zero");

			ByteVector rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.AreEqual (0, tag.Year, "Still zero");

			tag.Year = 1999;
			Assert.IsFalse (tag.IsEmpty, "Not empty");
			Assert.AreEqual (1999, tag.Year);

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsFalse (tag.IsEmpty, "Still not empty");
			Assert.AreEqual (1999, tag.Year);

			tag.Year = 20000;
			Assert.IsTrue (tag.IsEmpty, "Again empty");
			Assert.AreEqual (0, tag.Year, "Again zero");

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.AreEqual (0, tag.Year, "Still zero");
		}

		[Test]
		public void TestComment ()
		{
			Riff.DivXTag tag = new Riff.DivXTag ();

			Assert.IsTrue (tag.IsEmpty, "Initially empty");
			Assert.IsNull (tag.Comment, "Initially null");

			ByteVector rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.IsNull (tag.Comment, "Still null");

			tag.Comment = "01234567890123456789012345678901234567890123456789";
			Assert.IsFalse (tag.IsEmpty, "Not empty");
			Assert.AreEqual ("01234567890123456789012345678901234567890123456789", tag.Comment);

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsFalse (tag.IsEmpty, "Still not empty");
			Assert.AreEqual ("012345678901234567890123456789012345678901234567", tag.Comment);

			tag.Comment = string.Empty;
			Assert.IsTrue (tag.IsEmpty, "Again empty");
			Assert.IsNull (tag.Comment, "Again null");

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.IsNull (tag.Comment, "Still null");
		}

		[Test]
		public void TestGenres ()
		{
			Riff.DivXTag tag = new Riff.DivXTag ();

			Assert.IsTrue (tag.IsEmpty, "Initially empty");
			Assert.AreEqual (0, tag.Genres.Length, "Initially empty");

			ByteVector rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.AreEqual (0, tag.Genres.Length, "Still empty");

			tag.Genres = new string [] {"Action", "Comedy", "Non-Genre", "Claymation"};
			Assert.IsFalse (tag.IsEmpty, "Not empty");
			Assert.AreEqual ("Action", tag.JoinedGenres);

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsFalse (tag.IsEmpty, "Still not empty");
			Assert.AreEqual ("Action", tag.JoinedGenres);

			tag.Genres = new string [] {"Non-Genre"};
			Assert.IsTrue (tag.IsEmpty, "Surprisingly empty");
			Assert.AreEqual (0, tag.Genres.Length, "Surprisingly empty");

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.AreEqual (0, tag.Genres.Length, "Still empty");

			tag.Genres = new string [0];
			Assert.IsTrue (tag.IsEmpty, "Again empty");
			Assert.AreEqual (0, tag.Genres.Length, "Again empty");

			rendered = tag.Render ();
			tag = new Riff.DivXTag (rendered);
			Assert.IsTrue (tag.IsEmpty, "Still empty");
			Assert.AreEqual (0, tag.Genres.Length, "Still empty");
		}

		[Test]
		public void TestClear ()
		{
			Riff.DivXTag tag = new Riff.DivXTag ();

			tag.Title = "A";
			tag.Performers = new string [] {"B"};
			tag.Album = "C";
			tag.Year = 123;
			tag.Comment = "D";
			tag.Track = 234;
			tag.Genres = new string [] {"Blues"};

			Assert.IsFalse (tag.IsEmpty, "Should be full.");
			tag.Clear ();
			Assert.IsNull (tag.Title, "Title");
			Assert.AreEqual (0, tag.Performers.Length, "Performers");
			Assert.IsNull (tag.Album, "Album");
			Assert.AreEqual (0, tag.Year, "Year");
			Assert.IsNull (tag.Comment, "Comment");
			Assert.AreEqual (0, tag.Track, "Track");
			Assert.AreEqual (0, tag.Genres.Length, "Genres");
			Assert.IsTrue (tag.IsEmpty, "Should be empty.");
		}

		[Test]
		public void TestRender ()
		{
			ByteVector rendered = new Riff.DivXTag ().Render ();
			Assert.AreEqual (128, rendered.Count);
			Assert.IsTrue (rendered.EndsWith (Riff.DivXTag.FileIdentifier));
		}
	}
}