Exemplo n.º 1
0
        public static string[] GetAllTestTitles()
        {
            bool skipMethods;
            var  results = new List <string>();

            foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (t.Namespace == "YamlDotNet.Samples" && t.IsClass)
                {
                    skipMethods = false;
                    foreach (MethodInfo mi in t.GetMethods())
                    {
                        if (mi.Name == "Main")
                        {
                            SampleAttribute sa = (SampleAttribute)Attribute.GetCustomAttribute(mi, typeof(SampleAttribute));
                            if (sa != null)
                            {
                                results.Add(sa.Title);
                                skipMethods = true;
                                break;
                            }
                        }
                        if (skipMethods)
                        {
                            break;
                        }
                    }
                }
            }
            return(results.ToArray());
        }
Exemplo n.º 2
0
        private void Start()
        {
            bool skipMethods;

            foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (t.Namespace == "YamlDotNet.Samples" && t.IsClass && Array.IndexOf(disabledTests, t.Name) == -1)
                {
                    skipMethods = false;
                    foreach (MethodInfo mi in t.GetMethods())
                    {
                        if (mi.Name == "Main")
                        {
                            SampleAttribute sa = (SampleAttribute)Attribute.GetCustomAttribute(mi, typeof(SampleAttribute));
                            if (sa != null)
                            {
                                helper.WriteLine("{0} - {1}", sa.Title, sa.Description);
                                var testObject = t.GetConstructor(new Type[] { typeof(StringTestOutputHelper) }).Invoke(new object[] { helper });
                                mi.Invoke(testObject, new object[] {});
                                Debug.Log(helper.ToString());
                                helper.Clear();
                                skipMethods = true;
                                break;
                            }
                        }
                        if (skipMethods)
                        {
                            break;
                        }
                    }
                }
            }
        }