Exemplo n.º 1
0
        public void ReregisterManager()
        {
            ManualResetEvent handle = new ManualResetEvent(false);

            rig.Manager.TorrentStateChanged += delegate(object sender, TorrentStateChangedEventArgs e)
            {
                if (e.OldState == TorrentState.Hashing)
                {
                    handle.Set();
                }
            };
            rig.Manager.HashCheck(false);

            handle.WaitOne();
            handle.Reset();

            rig.Engine.Unregister(rig.Manager);
            TestRig rig2 = TestRig.CreateMultiFile(new TestWriter());

            rig2.Engine.Unregister(rig2.Manager);
            rig.Engine.Register(rig2.Manager);
            rig2.Manager.TorrentStateChanged += delegate(object sender, TorrentStateChangedEventArgs e)
            {
                if (e.OldState == TorrentState.Hashing)
                {
                    handle.Set();
                }
            };
            rig2.Manager.HashCheck(true);
            handle.WaitOne();
            rig2.Dispose();
        }
Exemplo n.º 2
0
        public void Setup()
        {
            _requestedUrl.Clear();
            partialData = false;
            int i;

            for (i = 0; i < 1000; i++)
            {
                try
                {
                    listener = new HttpListener();
                    listener.Prefixes.Add(string.Format(listenerURL, i));
                    listener.Start();
                    break;
                }
                catch
                {
                }
            }
            listener.BeginGetContext(GotContext, null);
            rig                = TestRig.CreateMultiFile();
            connection         = new HttpConnection(new Uri(string.Format(listenerURL, i)));
            connection.Manager = rig.Manager;

            id              = new PeerId(new Peer("this is my id", connection.Uri), rig.Manager);
            id.Connection   = connection;
            id.IsChoking    = false;
            id.AmInterested = true;
            id.BitField.SetAll(true);
            id.MaxPendingRequests = numberOfPieces;

            requests = rig.Manager.PieceManager.Picker.PickPiece(id, new List <PeerId>(), numberOfPieces);
        }
Exemplo n.º 3
0
 public void Setup()
 {
     pair = new ConnectionPair(55432);
     rig  = TestRig.CreateMultiFile();
     rig.Manager.HashChecked = true;
     rig.Manager.Start();
 }
Exemplo n.º 4
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
     id  = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), rig.Manager);
     for (int i = 0; i < id.BitField.Length; i += 2)
     {
         id.BitField[i] = true;
     }
 }
Exemplo n.º 5
0
 public virtual void Setup()
 {
     // Yes, this is horrible. Deal with it.
     rig    = TestRig.CreateMultiFile();
     peers  = new List <PeerId>();
     picker = new IgnoringPicker(rig.Manager.Bitfield, new StandardPicker());
     picker.Initialise(rig.Manager.Bitfield, rig.Manager.Torrent.Files, new List <Piece>());
     peer = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), rig.Manager);
     for (int i = 0; i < 20; i++)
     {
         PeerId p = new PeerId(new Peer(new string(i.ToString()[0], 20), new Uri("tcp://" + i)), rig.Manager);
         p.SupportsFastPeer = true;
         peers.Add(p);
     }
 }
Exemplo n.º 6
0
 public void GlobalSetup()
 {
     _rig = TestRig.CreateMultiFile();
 }
Exemplo n.º 7
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
 }
Exemplo n.º 8
0
 public void FixtureSetup()
 {
     _rig = TestRig.CreateMultiFile();
     _id  = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), _rig.Manager);
     _id.BitField.SetAll(true);
 }
Exemplo n.º 9
0
 public void Setup()
 {
     rig  = TestRig.CreateMultiFile(new TestWriter());
     conn = new ConnectionPair(51515);
 }
Exemplo n.º 10
0
 public void FixtureSetup()
 {
     _buffer  = new byte[100000];
     _testRig = TestRig.CreateMultiFile();
 }
Exemplo n.º 11
0
 public void FixtureSetup()
 {
     _rig         = TestRig.CreateMultiFile();
     _diskManager = _rig.Engine.DiskManager;
 }