public void LargeMultiTorrent() { string name1 = Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"); string name2 = Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"); string name3 = Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"); string name4 = Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"); string name5 = Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"); files = new List <TorrentFile>(new TorrentFile[] { new TorrentFile(name1, (long)(PieceLength * 200.30), 0, 1), new TorrentFile(name2, (long)(PieceLength * 42000.5), 1, 3), new TorrentFile(name3, (long)(PieceLength * 300.17), 3, 12), new TorrentFile(name4, (long)(PieceLength * 100.22), 12, 15), new TorrentFile(name5, (long)(PieceLength * 600.94), 15, 15), }); Torrent torrent = Torrent.Load(creator.Create("BaseDir", files)); Assert.Equal(5, torrent.Files.Length); Assert.Equal(name1, torrent.Files[0].Path); Assert.Equal(name2, torrent.Files[1].Path); Assert.Equal(name3, torrent.Files[2].Path); Assert.Equal(name4, torrent.Files[3].Path); Assert.Equal(name5, torrent.Files[4].Path); }
public void NoTrackersTest() { BEncodedDictionary dict = creator.Create("TorrentName", files); Torrent t = Torrent.Load(dict); Assert.Equal(0, t.AnnounceUrls.Count); }
public void CreateSingleFromFolder() { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); BEncodedDictionary dict = creator.Create(new TorrentFileSource(assembly.Location)); Torrent t = Torrent.Load(dict); Assert.AreEqual(1, t.Files.Length, "#1"); Assert.AreEqual(Path.GetFileName(assembly.Location), t.Name, "#2"); Assert.AreEqual(Path.GetFileName(assembly.Location), t.Files[0].Path, "#3"); // Create it again creator.Create(new TorrentFileSource(assembly.Location)); }
public void CreateMultiTest() { foreach (var v in announces) { creator.Announces.Add(v); } BEncodedDictionary dict = creator.Create("TorrentName", files); Torrent torrent = Torrent.Load(dict); VerifyCommonParts(torrent); for (int i = 0; i < torrent.Files.Length; i++) { Assert.True(files.Exists(delegate(TorrentFile f) { return(f.Equals(torrent.Files[i])); })); } }
public void CreateSingleFromFolder() { #if NETSTANDARD1_5 System.Reflection.Assembly assembly = this.GetType().GetTypeInfo().Assembly; #else System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); #endif BEncodedDictionary dict = creator.Create(new TorrentFileSource(assembly.Location)); Torrent t = Torrent.Load(dict); Assert.Equal(1, t.Files.Length); Assert.Equal(Path.GetFileName(assembly.Location), t.Name); Assert.Equal(Path.GetFileName(assembly.Location), t.Files[0].Path); // Create it again creator.Create(new TorrentFileSource(assembly.Location)); }
public void CreateSingleTest() { foreach (var v in announces) { creator.Announces.Add(v); } TorrentFile f = new TorrentFile(Path.GetFileName(files[0].Path), files[0].Length, files[0].StartPieceIndex, files[0].EndPieceIndex); BEncodedDictionary dict = creator.Create(f.Path, new List <TorrentFile> (new TorrentFile[] { f })); Torrent torrent = Torrent.Load(dict); VerifyCommonParts(torrent); Assert.Equal(1, torrent.Files.Length); Assert.Equal(f, torrent.Files[0]); }
/// <summary> /// /// </summary> public TorrentTest() { DateTime current = new DateTime(2006, 7, 1, 5, 5, 5); DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0); TimeSpan span = current - epochStart; creationTime = (long)span.TotalSeconds; Console.WriteLine(creationTime.ToString() + "Creation seconds"); BEncodedDictionary torrentInfo = new BEncodedDictionary(); torrentInfo.Add("announce", new BEncodedString("http://myannouceurl/announce")); torrentInfo.Add("creation date", new BEncodedNumber(creationTime)); torrentInfo.Add("nodes", new BEncodedList()); //FIXME: What is this? torrentInfo.Add("comment.utf-8", new BEncodedString("my big long comment")); torrentInfo.Add("comment", new BEncodedString("my big long comment")); torrentInfo.Add("azureus_properties", new BEncodedDictionary()); //FIXME: What is this? torrentInfo.Add("created by", new BEncodedString("MonoTorrent/" + VersionInfo.ClientVersion)); torrentInfo.Add("encoding", new BEncodedString("UTF-8")); torrentInfo.Add("info", CreateInfoDict()); torrentInfo.Add("private", new BEncodedString("1")); torrent = Torrent.Load(torrentInfo); }