Ejemplo n.º 1
0
        public void testGetLoadTimeWithCorrectURL(string url)
        {
            var nurl   = new Nurl();
            var result = nurl.getLoadTime(url);

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

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

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

            if (command.parse())
            {
                nurl.executeCommand(command);
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        public void testIsURL(string URL, Boolean expected)
        {
            var result = Nurl.isURL(URL);

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