public void TestDecodeStream() { using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { BencodeDecoder.Decode(ms); } }
public void TestBEncodeComplexString() { const string initialString = "d5:itemsli45e28:aBCdefghijklmnopqrstuvwxyz12ee"; IBElement[] result = BencodeDecoder.Decode(initialString); Assert.IsNotNull(result); string encodedString = string.Join("", result.Select(e => e.ToBencodedString())); Assert.AreEqual(initialString, encodedString, true); }
public void TestDecodeBInteger() { IBElement[] list = BencodeDecoder.Decode("i45e"); Assert.IsNotNull(list); Assert.AreEqual(1, list.Length); Assert.IsNotNull(list[0]); Assert.IsInstanceOfType(list[0], typeof(BInteger)); BInteger integer = (BInteger)list[0]; Assert.AreEqual(45L, integer.Value); }
public void TestDecodeBString() { IBElement[] list = BencodeDecoder.Decode("28:aBCdefghijklmnopqrstuvwxyz12"); Assert.IsNotNull(list); Assert.AreEqual(1, list.Length); Assert.IsNotNull(list[0]); Assert.IsInstanceOfType(list[0], typeof(BString)); BString str = (BString)list[0]; Assert.AreEqual("aBCdefghijklmnopqrstuvwxyz12", str.Value); }
public void TestDecodeBDictionary() { IBElement[] result = BencodeDecoder.Decode("d5:itemsli45e28:aBCdefghijklmnopqrstuvwxyz12ee"); Assert.IsNotNull(result); Assert.AreEqual(1, result.Length); Assert.IsNotNull(result[0]); Assert.IsInstanceOfType(result[0], typeof(BDictionary)); BDictionary dict = (BDictionary)result[0]; Assert.AreEqual(1, dict.Count); var item = dict.First(); Assert.IsNotNull(item); BString key = item.Key; Assert.IsNotNull(key); Assert.AreEqual("items", key.Value); Assert.IsNotNull(item.Value); Assert.IsInstanceOfType(item.Value, typeof(BList)); BList list = (BList)item.Value; Assert.AreEqual(2, list.Count); Assert.IsNotNull(list[0]); Assert.IsInstanceOfType(list[0], typeof(BInteger)); BInteger integer = (BInteger)list[0]; Assert.AreEqual(45L, integer.Value); Assert.IsNotNull(list[1]); Assert.IsInstanceOfType(list[1], typeof(BString)); BString str = (BString)list[1]; Assert.AreEqual("aBCdefghijklmnopqrstuvwxyz12", str.Value); }
public void TestDecodeBList() { IBElement[] result = BencodeDecoder.Decode("li45e28:aBCdefghijklmnopqrstuvwxyz12e"); Assert.IsNotNull(result); Assert.AreEqual(1, result.Length); Assert.IsNotNull(result[0]); Assert.IsInstanceOfType(result[0], typeof(BList)); BList list = (BList)result[0]; Assert.AreEqual(2, list.Count); Assert.IsNotNull(list[0]); Assert.IsInstanceOfType(list[0], typeof(BInteger)); BInteger integer = (BInteger)list[0]; Assert.AreEqual(45L, integer.Value); Assert.IsNotNull(list[1]); Assert.IsInstanceOfType(list[1], typeof(BString)); BString str = (BString)list[1]; Assert.AreEqual("aBCdefghijklmnopqrstuvwxyz12", str.Value); }
public void TestDecodeNullString() { Assert.ThrowsException <ArgumentNullException>(() => BencodeDecoder.Decode(bencodedValue: null)); }
public void TestDecodeInvalidBIteger_4() { BencodeDecoder.Decode("ie"); }
public void TestDecodeInvalidBIteger_3() { BencodeDecoder.Decode("45e"); }
public void TestDecodeInvalidBIteger_1() { BencodeDecoder.Decode("i45"); }
public void TestDecodeInvalidBElement_1() { Assert.ThrowsException <BencodingException>(() => BencodeDecoder.Decode("k")); }
public void TestDecodeInvalidBElement_1() { BencodeDecoder.Decode("k"); }
public void TestDecodeInvalidBIteger_4() { Assert.ThrowsException <BencodingException>(() => BencodeDecoder.Decode("ie")); }
public void TestDecodeNullStream() { BencodeDecoder.Decode(input: null); }
public void TestDecodeInvalidBString_1() { Assert.ThrowsException <BencodingException>(() => BencodeDecoder.Decode(":aze")); }
public void TestDecodeNullStream() { Assert.ThrowsException <ArgumentNullException>(() => BencodeDecoder.Decode(input: null)); }
public void TestDecodeEmptyString() { IBElement[] result = BencodeDecoder.Decode(""); Assert.IsNotNull(result); Assert.AreEqual(0, result.Length); }
public void TestDecodeNullString() { BencodeDecoder.Decode(bencodedValue: null); }
public void TestDecodeInvalidBString_3() { BencodeDecoder.Decode("5:"); }
public void TestDecodeInvalidBString_2() { BencodeDecoder.Decode("5:aze"); }