Example #1
0
        // 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);
                            }
                        }
                    }
                }
            }
        }