public void RunTests()
        {
            SimpleLog.SetLogDir("D:\\test", true);
            var classes = GetClassTypesWith <ApiTest>(true);

            SimpleLog.Info("API Testing started....");
            foreach (var type in classes)
            {
                SimpleLog.Info("UseCases in class " + type.Name + " is invoked");
                object classInstance     = type.Assembly.CreateInstance(type.FullName);
                var    InitializeMethods = type.GetMethods().Where(m => m.GetCustomAttributes(typeof(ApiClassInitialize), false).Length > 0).ToArray();
                foreach (var testmethod in InitializeMethods)
                {
                    object[] obj = new object[] { link };
                    testmethod.Invoke(classInstance, obj);
                }
                var methods = type.GetMethods().Where(m => m.GetCustomAttributes(typeof(ApiUseCase), false).Length > 0).ToArray();
                foreach (var testmethod in methods)
                {
                    SimpleLog.Info("Usecase " + testmethod.Name + " is invoked");
                    TestInfo testinfo = new TestInfo();
                    try
                    {
                        testinfo.ClassName  = classInstance.GetType().ToString();
                        testinfo.MethodName = testmethod.Name;
                        testmethod.Invoke(classInstance, null);
                        testinfo.TestSuccess = true;
                        SimpleLog.Info("Usecase Successfully completed");
                    }
                    catch (TargetInvocationException e)
                    {
                        SimpleLog.Info("Usecase Failed");
                        testinfo.TestSuccess  = false;
                        testinfo.errorMessage = e.InnerException.Message;
                        SimpleLog.Log(e.InnerException);
                    }catch (Exception e)
                    {
                        SimpleLog.Info("Usecase Failed");
                        testinfo.TestSuccess  = false;
                        testinfo.errorMessage = e.Message;
                        SimpleLog.Log(e);
                    }
                    TestResults.Add(testinfo);
                }
            }
            SimpleLog.ShowLogFile();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            SimpleLog.SetLogFile("logs", writeText: true);

            // read necessary data
            var isConfigReaded = FileHandler.ReadConfig(Settings.ConfigFileName, out List <Settings> settings);

            if (!isConfigReaded)
            {
                var msg = "Error while reading config file. See log file for details.";
                Console.WriteLine(msg);
                SimpleLog.Log(msg);
            }
            else
            {
                foreach (var setting in settings)
                {
                    try
                    {
                        ParseLeague(setting);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        SimpleLog.Log(e);
                    }
                }
            }

            Console.WriteLine("Finished! Press l to view logs, c to close all excel instances or any other key to exit.");
            var key = Console.ReadKey();

            if (key.KeyChar == 'l' || key.KeyChar == 'L')
            {
                SimpleLog.ShowLogFile();
            }
            if (key.KeyChar == 'c' || key.KeyChar == 'C')
            {
                foreach (var s in settings)
                {
                    s?.Excel?.CloseFile();
                }
            }
            SimpleLog.StopLogging();
        }
Ejemplo n.º 3
0
 private void btnSmpLogs_Click(object sender, EventArgs e)
 {
     SimpleLog.ShowLogFile();
 }