public void TestFichierNonSaisissable(string chemfic) { var nurl = new ClassNURL(); bool b = nurl.IsFichier(chemfic); Assert.IsFalse(b, "Test renvoie false car fichier non saisissable"); }
public void TestIsFichier(string chemfic) { var nurl = new ClassNURL(); bool b = nurl.IsFichier(chemfic); Assert.IsTrue(b, "Test renvoie true, fichier existant"); }
public void TestIsNotFichier(string chemfic) { var nurl = new ClassNURL(); bool b = nurl.IsFichier(chemfic); Assert.IsFalse(b, "Test renvoie false pour un mauvais chemein de fichier"); }
public void TestISNOTURL(string url) { var nurl = new ClassNURL(); bool b = nurl.IsURL(url); Assert.IsFalse(b, "Test renvoie false pour une mauvaise url"); }
public void TestISURL(string url) { var nurl = new ClassNURL(); bool b = nurl.IsURL(url); Assert.IsTrue(b, "Test renvoie true pour une bonne url"); }
public void TestGetWrongURLSource(string url, string source) { var nurl = new ClassNURL(); string s = nurl.GetSource(url); Assert.AreEqual(s, source, "Test renvoie bien une erreur"); }
// [TestCase(new string[] {"get", "-url", "http://www.perdu.com/", "-save", @"C:\Temp\test.txt"},true)] // [TestCase(new string[] {"test", "-url", "http://www.perdu.com/", "-times", "5"},true)] // [TestCase(new string[] {"test", "-url", "http://www.perdu.com/", "-times", "5", "-avg"},true)] // [TestCase(new string[] {"get", "-url", "wrong"},false)] // [TestCase(new string[] {"get","-durl", "http://www.perdu.com/"},false)] // [TestCase(new string[] {"getd", "-url", "http://www.perdu.com/", "-save", @"C:\Temp\test.txt"},false)] // [TestCase(new string[] {"get", "-url","http://www.perdu.com/", "-save", "rrr"},false)] // [TestCase(new string[] {"get", "-url", "http://www.perdu.com/", "-savedzz", @"C:\Temp\test.txt"},false)] // [TestCase(new string[] {"test", "-urdl", "http://www.perdu.com/", "-times", "5"},false)] // [TestCase(new string[] {"testd", "-url", "http://www.perdu.com/", "-times", "5"},false)] // [TestCase(new string[] {"test", "-url", "http://www.perdu.com/", "-timesd", "5"},false)] // [TestCase(new string[] {"test", "-url", "wrong", "-timesd", "5"},false)] // [TestCase(new string[] {" testz", "-url", "http://www.perdu.com/", "-times", "5", "-avg"},false)] // [TestCase(new string[] {" test", "-urls", "http://www.perdu.com/", "-timesd", "5", "-avg"},false)] // [TestCase(new string[] {" test", "-url", "http://www.perdu.com/", "-times","5", "-avgd"},false)] // [TestCase(new string[] {" test", "-url", "wrong", "-times", "5", "-avgd "},false)] public void TestArguments(string[] args, bool err) { var nurl = new ClassNURL(); var ga = new GestionArguments(args); Assert.AreEqual(ga.VerifieArguments(), err, "Gestion des arguments"); }
public void Gestion() { if (VerifieArguments()) { ClassNURL n = new ClassNURL(); if (get && url && !save) { n.AfficheSource(args[2]); } if (get && save && url) { string s = n.GetSource(args[2]); n.EcritureFichier(args[4], s); } if (test && times && !avg) { double[] lestemps = n.getTime(args[2], int.Parse(args[4])); n.AfficheTemps(lestemps); } if (test && times && avg) { double[] lestemps = n.getTime(args[2], int.Parse(args[4])); n.AfficheMoy(lestemps); } } else { Console.WriteLine("Erreur dans les arguments"); } }
public void TestAVG() { double[] results = new double[3]; results[0] = 6.3; results[1] = 2.0; results[2] = 3.6; var nurl = new ClassNURL(); Assert.AreEqual(3.9666666666666668, nurl.calculAVG(results), "Test renvoie bonne moyenne"); }
public bool VerifieArguments() { ClassNURL n = new ClassNURL(); if (args.Length < 3 || args.Length > 6 || args.Length == 4) { return(false); } //3 premiers arguments if (args[0].Equals("get", StringComparison.OrdinalIgnoreCase)) { get = true; if (args[1].Equals("-url", StringComparison.OrdinalIgnoreCase)) { if (n.IsURL(args[2])) { url = true; } else { return(false); } } else { return(false); } } else if (args[0].Equals("test", StringComparison.OrdinalIgnoreCase)) { test = true; if (args[1].Equals("-url", StringComparison.OrdinalIgnoreCase)) { if (n.IsURL(args[2])) { url = true; } else { return(false); } } else { return(false); } } else { return(false); } //autres arguments if (args.Length > 3) { if (get) { if (args[3].Equals("-save", StringComparison.OrdinalIgnoreCase)) { save = true; if (n.IsFichier(args[4])) { fic = true; return(true); } else { return(false); } } else { return(false); } } if (test) { if (args[3].Equals("-times", StringComparison.OrdinalIgnoreCase)) { times = true; int i; if (Int32.TryParse(args[4], out i)) { if (args.Length == 6) { if (args[5].Equals("-avg", StringComparison.OrdinalIgnoreCase)) { avg = true; return(true); } else { return(false); } } else { return(true); } } else { return(false); } } else { return(false); } } } else { if (get) { return(true); } if (test) { return(false); } } return(true); }