Exemple #1
0
        public void StandardPicker_PickStandardPiece()
        {
            peers [0].IsChoking = false;
            peers [0].BitField.SetAll(true);

            rig.Manager.Bitfield [1] = true;
            var message = standardPicker.PickPiece(peers [0], rig.Manager.Bitfield.Clone().Not(), peers, 1, 0, 10);

            Assert.AreEqual(0, message[0].PieceIndex);

            peers [1].IsChoking = false;
            peers [1].BitField.SetAll(true);
            peers [1].Peer.HashedPiece(false);
            message = standardPicker.PickPiece(peers [1], rig.Manager.Bitfield.Clone().Not(), peers, 1, 0, 10);
            Assert.AreEqual(2, message[0].PieceIndex);
        }
Exemple #2
0
        public void SmallTorrent_InitializeSwitcher_NoExisting()
        {
            Switcher.Initialise(SmallTorrent.Bitfield, SmallTorrent, Enumerable.Empty <Piece> ());
            Assert.AreEqual(0, Endgame.ExportActiveRequests().Count, "#1");
            Assert.AreEqual(0, Standard.ExportActiveRequests().Count, "#2");
            Assert.AreSame(Standard, Switcher.ActivePicker, "#3");

            Assert.IsNotNull(Standard.PickPiece(SmallTorrent.Seeder, SmallTorrent.Seeder.BitField, Array.Empty <IPieceRequester> ()), "#4");
            Assert.IsNotNull(Endgame.PickPiece(SmallTorrent.Seeder, SmallTorrent.Seeder.BitField, Array.Empty <IPieceRequester> ()), "#5");
        }