public void TestMarkPieceLocalWithInvalidPieceNumber() { MetaInfoFile file = new MetaInfoFile(Constants.SingleFileTorrent); file.Parse(); TorrentContext tc = new TorrentContext(file, new Selector(), new DiskIO(new Manager()), Constants.DestinationDirectory); Assert.Throws <IndexOutOfRangeException>(() => tc.MarkPieceLocal(Constants.InvalidPieceNumber, true)); }
public void TestAskForZeroPiecesFromLocalPeerSuggestions() { MetaInfoFile file = new MetaInfoFile(Constants.SingleFileTorrent); file.Parse(); Manager manager = new Manager(); TorrentContext tc = new TorrentContext(file, new Selector(), new DiskIO(manager), Constants.DestinationDirectory); Selector selector = new Selector(); Peer peer = new Peer("127.0.0.1", 6881, tc, new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0)); for (UInt32 pieceNumber = 0; pieceNumber < tc.numberOfPieces; pieceNumber++) { tc.IncrementPeerCount(pieceNumber); tc.MarkPieceLocal(pieceNumber, true); } UInt32[] pieces = selector.LocalPieceSuggestions(peer, 0); Assert.Empty(pieces); }