Example #1
0
        public void TorrentPropertiesTest()
        {
            UInt32 handle    = 101;
            string name      = "TorrentName";
            Int64  totalSize = (1024 * 1024);

            //double percentDone = 47.7d;
            TorrentMetaData.TorrentState state = TorrentMetaData.TorrentState.PeerMode;
            UInt32 numPeers      = 10;
            UInt32 numSeeds      = 5;
            UInt32 downloadSpeed = 2048;
            UInt32 uploadSpeed   = 512;
            Int64  eta           = 100000;

            Torrent target = new Torrent(handle)
            {
                Id = handle, Name = name, TotalSize = totalSize, /*PercentDone = percentDone, */ State = state, NumPeers = numPeers, NumSeeds = numSeeds, DownloadSpeed = downloadSpeed, UploadSpeed = uploadSpeed, Eta = eta
            };

            Assert.AreEqual(target.Handle, handle);
            Assert.AreEqual(target.Name, name);
            Assert.AreEqual(target.TotalSize, totalSize);
            //Assert.AreEqual(target.PercentDone, percentDone);
            Assert.AreEqual(target.State, state);
            Assert.AreEqual(target.NumPeers, numPeers);
            Assert.AreEqual(target.NumSeeds, numSeeds);
            Assert.AreEqual(target.DownloadSpeed, downloadSpeed);
            Assert.AreEqual(target.UploadSpeed, uploadSpeed);
            Assert.AreEqual(target.Eta, eta);
        }
Example #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            TorrentMetaData.TorrentState state = (TorrentMetaData.TorrentState)System.Convert.ToInt32(value);
            switch (state)
            {
            case TorrentMetaData.TorrentState.Stopped:
                return(String.Format("Stopped"));

            case TorrentMetaData.TorrentState.CreateFiles:
                return(String.Format("Creating Files"));

            case TorrentMetaData.TorrentState.PeerMode:
                return(String.Format("Downloading"));

            case TorrentMetaData.TorrentState.SeedMode:
                return(String.Format("Seeding"));

            case TorrentMetaData.TorrentState.Queued:
                return(String.Format("Queued"));

            case TorrentMetaData.TorrentState.Rechecking:
                return(String.Format("Checking"));
            }
            throw new Exception("Invalid state");
        }