Exemple #1
0
        public static void Main(string[] args)
        {
            using (var outputLogger = new OutputLogger())
            {
                if (args.Length < 3)
                {
                    outputLogger.Log("Required arguments: host-ip username password");
                    return;
                }

                //Trust all certificates. This is a test workaround. DO NOT USE IN PRODUCTION CODE!
                ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

                Session session = null;
                try
                {
                    string hostname = args[0], username = args[1], password = args[2];
                    session = new Session(hostname, 443); //using the default port
                    session.login_with_password(username, password, "", "XenSdkSample");

                    int pass = 0, fail = 0;

                    var testList = new List <TestBase>
                    {
                        new GetVariousRecords(outputLogger, session),
                        new VmPowerStates(outputLogger, session)
                    };

                    using (var resultLogger = new ResultLogger())
                    {
                        resultLogger.Initialise();
                        foreach (var test in testList)
                        {
                            try
                            {
                                test.Run();
                                pass++;
                                resultLogger.LogTest(test.Name, true, "");
                            }
                            catch (Exception e)
                            {
                                fail++;
                                resultLogger.LogTest(test.Name, false, e.Message);
                            }
                        }

                        resultLogger.Finalise(testList.Count, pass, fail);
                    }
                }
                finally
                {
                    if (session != null)
                    {
                        session.logout();
                    }
                }
            }
        }
Exemple #2
0
 public GetVariousRecords(OutputLogger logger, Session session)
     : base(logger, session)
 {
 }
Exemple #3
0
 protected TestBase(OutputLogger logger, Session session)
 {
     _logger  = logger;
     _session = session;
 }
Exemple #4
0
 public VmPowerStates(OutputLogger logger, Session session)
     : base(logger, session)
 {
 }