/// <summary> /// Punto de entrada /// </summary> public static void Main() { String path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName); UriBuilder builder = new UriBuilder("file", "", 0, path); String uri = builder.Uri.ToString(); // Creamos un nuevo descargador pasándole una ubicación. Downloader downloader = new Downloader(uri); // Pedimos al descargador que descargue el contenido string content; //Carga el contenido del archivo en la variable content content = downloader.Download(); //Busca las tags y sus correspondientes atributos Finder finder = new Finder(); List <Tag> tags = finder.Find(content); //Formatea las tags y sus atributos para mostrarlos de la manera deseada Formater formater = new Formater(); List <string> formatedTags = formater.Format(tags); //Muestra en pantalla las tags con sus atributos Printer printer = new Printer(); printer.Print(formatedTags); }
// metodo utilizado por todos los tests, compara los elementos de la List<> expectedTags con los elementos // de la lista que resulta de aplicar el metodo Finder public static void ComparatorMethod(string input, List <Tag> expectedTags) { Finder finder = new Finder(); List <Tag> resultTags = finder.Find(input); Assert.Equal(expectedTags.Count, resultTags.Count); if (expectedTags.Count == resultTags.Count) { for (int i = 0; i < resultTags.Count; i++) { Assert.Equal(resultTags[i].Name, expectedTags[i].Name); if (resultTags[i].AttributeList != null & expectedTags[i].AttributeList != null) { Assert.Equal(resultTags[i].AttributeList.Count, expectedTags[i].AttributeList.Count); if (resultTags[i].AttributeList.Count > 0 & expectedTags[i].AttributeList.Count > 0 & resultTags[i].AttributeList.Count == expectedTags[i].AttributeList.Count) { foreach (KeyValuePair <string, Attribute> entry in resultTags[i].AttributeList) { //entry.key //resultTags[i].AttributeList[entry.key] bool encontro; try { Attribute attribute = expectedTags[i].AttributeList[entry.Key]; encontro = true; } catch (System.Exception) { encontro = false; } Assert.True(encontro); } } } } } }