Esempio n. 1
0
        public async Task ScenarioTypicalUse()
        {
            var api = new Api(_serverCredential);

            var resultAddTorrent = await api.AddTorrent(_freeMusicTorrentFile);
            Assert.True(resultAddTorrent);
            Thread.Sleep(60*1000);

            var torrents = await api.GetTorrents();
            Assert.True(torrents.Count == 1);
            Assert.Equal(_freeMusicTorrentHash, torrents.First().InfoHash);

            var properties = await api.GetProperties(_freeMusicTorrentHash);

            properties.Label = "free-music";
            var resultSetProperty = await api.SetProperties(_freeMusicTorrentHash, properties);
            Assert.True(resultSetProperty);
            Thread.Sleep(1500);
            var torrentsAfterLabelChange = await api.GetTorrents();
            Assert.Equal(properties.Label, torrentsAfterLabelChange.First().Label);

            Thread.Sleep(1500);
            var files = await api.GetFiles(_freeMusicTorrentHash);
            var rnd = new Random();
            var randomFileIndex = rnd.Next(files.Count);
            var setFilePriorityResult = await api.SetFilePriority(_freeMusicTorrentHash, randomFileIndex, 0);
            Assert.True(setFilePriorityResult);

            // TODO : Investigate why peers are sometimes unavailable
            //var peers = await api.GetPeers(_freeMusicTorrentHash);
            //Assert.True(peers.Count > 0);

            var deleteResult = await api.Perform(Action.Removedata, _freeMusicTorrentHash);
            Assert.True(deleteResult);
            Thread.Sleep(1500);
            Assert.True((await api.GetTorrents()).Count == 0);
        }