public void Should_Show_Average_Times()
        {
            string[] args = new string[]{"test","-url","google.Fr","-times","4"};
            string theUrl=args[2];
            int nb=Convert.ToInt32(args[4]);
            var n=new NURL(theUrl);
            var sn=new SaveNURL(n);
            sn.TestAverageLoadingUrl(theUrl,nb);
            TimeSpan ts=sn.TimeAverage;

            Assert.AreEqual(ts,sn.TimeAverage);
        }
        public void Should_Show_Times()
        {
            string[] args = new string[]{"test","-url","http://api.openweathermap.org/data/2.5/weather?q=paris&units=metric","-times","4"};
            string theUrl=args[2];
            int nb=Convert.ToInt32(args[4]);
            var n=new NURL(theUrl);
            var sn=new SaveNURL(n);
            ArrayList ts=new ArrayList();

            StringBuilder sb = new StringBuilder();
            sn.getTimeSpans(theUrl,nb,ts);

            for (int i = 0; i < ts.Count; i++)
            {
                sb.Append(ts[i]+"\n");
            }

            Assert.AreEqual(sb.ToString(),sb.ToString());
        }
Пример #3
0
        public static void Main(string[] args)
        {
            string path;
            string extension;

            NURL n=new NURL(args[2]);
            GetNURL gn=new GetNURL(n);
            SaveNURL sn=new SaveNURL(n);

            if(args[0] =="get")
            {
                if(args[1]=="-url")
                {
                    n.Url=args[2];
                    n.Url=n.AddHttp(n.Url);
                    n.ExistURL(n.Url);

                    if(args.Length<4)
                    {
                        gn.DisplayHtml(n.Url);
                    }
                    else
                    {
                        if(args[3]=="-save")
                        {
                            path=args[4];
                            extension=args[4].Substring(args[4].LastIndexOf(".")+1);
                            gn.SaveContent(n.Url,path);
                        }
                    }

                }

            }
            else
            {
                if(args[0]=="test")
                {
                    if(args[1]=="-url")
                    {
                        n.Url=args[2];
                        n.Url=n.AddHttp(n.Url);
                        if(args.Length<6)
                        {
                            sn.TestLoadingUrl(n.Url,Convert.ToInt32(args[4]));
                        }
                        else
                        {
                            sn.TestAverageLoadingUrl(n.Url,Convert.ToInt32(args[4]));
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Cette option n'existe pas.");
                }
            }

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }