public void When_calling_Stop_should_call_Exit_on_IProcessStarter() { var mockProcessStarter = new Mock<IProcessStarter>(); var fakeLogger = new Mock<Logger>(); var fakeRunner = new Mock<IServerValidationRunner>(); var fakeWatcher = new Mock<IServerWatcher>(); IServer server = new Aria2cServer(mockProcessStarter.Object, fakeRunner.Object, new Aria2cConfig(), fakeLogger.Object, fakeWatcher.Object); server.Stop(); mockProcessStarter.Verify(c => c.Exit(), Times.Once()); }
public void Add_download() { string appRoot = @"C:\work\aria4net"; var fakeFomatter = new Mock<IPathFormatter>(); var logger = LogManager.GetCurrentClassLogger(); var config = new Aria2cConfig { Executable = Path.Combine(appRoot, "tools\\aria2-1.16.3-win-32bit-build1\\aria2c.exe"), Id = Guid.NewGuid().ToString(), JsonrpcUrl = "http://localhost:6800/jsonrpc", JsonrpcVersion = "2.0", WebSocketUrl = "ws://localhost:6800/jsonrpc" }; var watcher = new Aria2cWebSocketWatcher(config, logger); IServer server = new Aria2cServer( new Aria2cProcessStarterWithWindow( new Aria2cFinder(config, fakeFomatter.Object), config, logger) { DownloadedFilesDirPath = () => "c:\\temp" }, new DefaultValidationRunner(), config, logger, watcher); server.Start(); IClient client = new Aria2cJsonRpcClient(config, watcher, logger); client.AddTorrent( "ftp://download.warface.levelupgames.com.br/Warface/Installer/Instalador_Client_LevelUp_1.0.34.006.torrent"); server.Stop(); }
private static void Main(string[] args) { string appRoot = Path.GetDirectoryName( Path.GetDirectoryName( Path.GetDirectoryName( Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))))); var logger = LogManager.GetCurrentClassLogger(); var config = new Aria2cConfig { Executable = Path.Combine(appRoot, "tools\\aria2-1.16.3-win-32bit-build1\\aria2c.exe"), Id = "downloader-session" }; var watcher = new Aria2cWebSocketWatcher(config, logger); IServer server = new Aria2cServer( new Aria2cProcessStarter( new Aria2cFinder(config, new DefaultPathFormatter(new WindowsPathTokenizer())), config, logger) { DownloadedFilesDirPath = () => "c:\\temp" }, new DefaultValidationRunner(), config, logger, watcher); server.Start(); IClient client = new Aria2cJsonRpcClient(config, watcher, logger); client.ChangeDestinationPath(@"C:\temp\torrents"); var url1 = "http://download.warface.levelupgames.com.br/Warface/Installer/Instalador_Client_LevelUp_1.0.34.006.torrent"; var gid1 = ""; client.DownloadCompleted += (sender, eventArgs) => Console.WriteLine("Download concluido {0}", eventArgs.Status.Gid); client.DownloadProgress += (o, e) => Console.WriteLine( "\r{7} Status {5} | Progress {0:N1} % | Speed {1:N2} Mb/s | Eta {2:N0} s | Downloaded {3:N2} Mb | Remaining {6:N2} Mb | Total {4:N2} Mb", e.Status.Progress, e.Status.DownloadSpeed.ToMegaBytes(), e.Status.Eta, e.Status.CompletedLength.ToMegaBytes(), e.Status.TotalLength.ToMegaBytes(), e.Status.Status, (e.Status.Remaining).ToMegaBytes(), e.Status.Gid); gid1 = client.AddTorrent(url1, new[] {1}); Console.ReadKey(); client.Shutdown(); }
public void Start_stop_server() { string appRoot = @"C:\work\aria4net"; var fakeWatcher = new Mock<IServerWatcher>(); var fakeFomatter = new Mock<IPathFormatter>(); var logger = LogManager.GetCurrentClassLogger(); var config = new Aria2cConfig { Executable = Path.Combine(appRoot, "tools\\aria2-1.16.3-win-32bit-build1\\aria2c.exe") }; IServer server = new Aria2cServer( new Aria2cProcessStarterWithWindow( new Aria2cFinder(config, fakeFomatter.Object), config, logger), new DefaultValidationRunner(), config, logger, fakeWatcher.Object); server.Start(); Thread.Sleep(1000); server.Stop(); }