public void ParseMagnetLink() { InfoHash hash = Create(); string magnet = string.Format("magnet:?xt=urn:btih:{0}", hash.ToHex()); MagnetLink other = MagnetLink.Parse(magnet); Assert.AreEqual(hash, other.InfoHash, "#1"); }
public void HexTest() { InfoHash hash = Create(); string hex = hash.ToHex(); Assert.AreEqual(40, hex.Length, "#1"); InfoHash other = InfoHash.FromHex(hex); Assert.AreEqual(hash, other, "#2"); }
public void InvalidMagnetLink2() { InfoHash hash = Create(); string magnet = string.Format("magnet:?xt=urn:btih:", hash.ToHex()); MagnetLink other = new MagnetLink(magnet); Assert.AreEqual(hash, other.InfoHash, "#1"); }
public void ParseMagnetLink() { InfoHash hash = Create(); string magnet = $"magnet:?xt=urn:btih:{hash.ToHex ()}"; MagnetLink other = MagnetLink.Parse(magnet); Assert.AreEqual(hash, other.InfoHashes.V1, "#1"); }
public void InvalidMagnetLink3() { Assert.Throws <FormatException> (() => { InfoHash hash = Create(); string magnet = string.Format("magnet:?xt=urn:btih:", hash.ToHex()); MagnetLink other = MagnetLink.Parse(magnet); Assert.AreEqual(hash, other.InfoHash, "#1"); }); }
public void InvalidMagnetLink() { Assert.Throws <UriFormatException> (() => { InfoHash hash = Create(); string magnet = $"magnet?xt=urn:btih:{hash.ToHex ()}"; MagnetLink other = MagnetLink.Parse(magnet); Assert.AreEqual(hash, other.InfoHash, "#1"); }); }
//[ExpectedException(typeof(FormatException))] public void InvalidMagnetLink() { Assert.Catch <FormatException>(() => { InfoHash hash = Create(); string magnet = string.Format("magnet?xt=urn:btih:{0}", hash.ToHex()); MagnetLink other = new MagnetLink(magnet); Assert.AreEqual(hash, other.InfoHash, "#1"); }); }
public void InfoHashTest() { MagnetLink link = MagnetLink.Parse("magnet:?xt.1=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C"); Assert.AreEqual(InfoHash.FromBase32("YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C"), link.InfoHash, "#1"); //base32 InfoHash initial = new InfoHash(System.Text.Encoding.ASCII.GetBytes("foobafoobafoobafooba")); link = MagnetLink.Parse("magnet:?xt=urn:sha1:MZXW6YTBMZXW6YTBMZXW6YTBMZXW6YTB"); Assert.AreEqual(initial, link.InfoHash, "#2"); //base40 = hex InfoHash hash = Create(); string hex = hash.ToHex(); link = MagnetLink.Parse("magnet:?xt=urn:btih:" + hex); Assert.AreEqual(hash, link.InfoHash, "#3"); }
public void InvalidMagnetLink4() { Assert.Throws <FormatException> (() => { InfoHash hash = Create(); string magnet = string.Format("magnet:?xt=urn:btih:23526246235623564234365879634581726345981", hash.ToHex()); MagnetLink other = MagnetLink.Parse(magnet); Assert.AreEqual(hash, other.InfoHash, "#1"); }); }
public void InvalidMagnetLink3() { InfoHash hash = Create(); string magnet = string.Format("magnet:?xt=urn:btih:23526246235623564234365879634581726345981", hash.ToHex()); MagnetLink other = new MagnetLink(magnet); Assert.AreEqual(hash, other.InfoHash, "#1"); }