Exemple #1
0
        public void testGetLoadTimeWithCorrectURL(string url)
        {
            var nurl   = new Nurl();
            var result = nurl.getLoadTime(url);

            Assert.IsTrue(result > 0, "Erreur testGetLoadTimeWithCorrectURL");
        }
Exemple #2
0
        public void testGetLoadTimeWithWrongURL(string url, float expected)
        {
            var nurl   = new Nurl();
            var result = nurl.getLoadTime(url);

            Assert.AreEqual(result, expected, "Erreur testGetLoadTimeWithWrongURL");
        }
Exemple #3
0
        public void testGetContent(string url, string expected)
        {
            var nurl   = new Nurl();
            var result = nurl.getContent(url);

            Assert.AreEqual(result, expected, "Erreur testGetContent");
        }
        public static void Main(string[] args)
        {
            Command command = new Command(args);
            Nurl    nurl    = new Nurl();

            if (command.parse())
            {
                nurl.executeCommand(command);
            }
        }
        public float getLoadTime(string URL)
        {
            float loadTime = 0;

            if (Nurl.isURL(URL))
            {
                var timeBefore = DateTime.Now;
                getContent(URL);
                var timeAfter = DateTime.Now;
                loadTime = (timeAfter - timeBefore).Milliseconds;
            }
            return(loadTime);
        }
        public string getContent(string URL)
        {
            string content = "";

            if (Nurl.isURL(URL))
            {
                var webClient = new System.Net.WebClient();
                content = webClient.DownloadString(URL);
                //Suppression du retour à la ligne '\n'
                content = content.Remove(content.Length - 1);
            }

            return(content);
        }
Exemple #7
0
        public void testIsURL(string URL, Boolean expected)
        {
            var result = Nurl.isURL(URL);

            Assert.AreEqual(result, expected, "Erreur testIsURL");
        }