Exemple #1
0
        public void Download_Speed_Test()
        {
            string dlUrl       = @"http://asciiserver.westus2.cloudapp.azure.com:8080/downloads/bigJsonFile.json";
            var    dlSpeedtest = DownloadSpeedTest.Download(dlUrl, ".");

            Assert.IsNotNull(dlSpeedtest, "download failed");

            if (dlSpeedtest != null)
            {
                this.LogTest.Info($"Download Size: {dlSpeedtest.Size} bytes");
                this.LogTest.Info($"Time taken: {dlSpeedtest.TimeTaken,6:f} s");
                this.LogTest.Info($"Download speed: {dlSpeedtest.DownloadSpeed,6:f} Mbps");
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args is null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            var path         = "Config.json";
            var GetDirectory = Path.GetFullPath(path);



            StreamReader r = new StreamReader(path);



            var json = r.ReadToEnd();
            var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);

            r.Close();

            var downloadPath = dict["FileToProcessDownloadUri"];
            var uploadPath   = dict["FileToProcessUploadUri"];


            try
            {
                //# Passing the path with the directory where we'll download from
                DownloadSpeedTest downloadSpeedTest = new DownloadSpeedTest(downloadPath);
                //# Passing the path with the file where we'll upload to
                UploadSpeedTest uploadSpeedTest = new UploadSpeedTest(uploadPath);

                Console.WriteLine($"Start{Environment.NewLine}");
                Console.WriteLine("Calculating download speed...");
                Console.WriteLine($"Ping: {downloadSpeedTest.GetPing().ToString()} ms");
                Console.WriteLine(downloadSpeedTest.GetSpeedResult());
                Console.WriteLine("-----");

                Console.WriteLine("Calculating upload speed...");
                Console.WriteLine($"Ping: {uploadSpeedTest.GetPing()} ms");
                Console.WriteLine(uploadSpeedTest.GetSpeedResult());
                Console.WriteLine($"{Environment.NewLine}End");


                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }