示例#1
0
        public void AnnounceWhenComplete()
        {
            TrackerManager.AddTracker("http://1.1.1.1");
            Manager.LoadFastResume(new FastResume(Manager.InfoHash, Manager.Bitfield.Clone().SetAll(true), Manager.Bitfield.Clone().SetAll(false)));

            Manager.Bitfield[0] = false;
            var mode = new DownloadMode(Manager, DiskManager, ConnectionManager, Settings);

            Manager.Mode = mode;

            Assert.AreEqual(1, TrackerManager.Announces.Count, "#0");
            Assert.AreEqual(TorrentState.Downloading, Manager.State, "#0b");
            Assert.AreEqual(TorrentEvent.None, TrackerManager.Announces[0].Item2, "#0");

            Manager.Bitfield[0] = true;
            TrackerManager.Announces.Clear();
            mode.Tick(0);
            Assert.AreEqual(TorrentState.Seeding, Manager.State, "#0c");

            Assert.AreEqual(2, TrackerManager.Announces.Count, "#1");
            Assert.AreEqual(TrackerManager.CurrentTracker, TrackerManager.Announces[0].Item1, "#2");
            Assert.AreEqual(TorrentEvent.None, TrackerManager.Announces[0].Item2, "#3");
            Assert.AreEqual(TorrentEvent.Completed, TrackerManager.Announces[1].Item2, "#4");
        }