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(); } } } }
public void Run() { _logger.Log("*** Test {0} ***", Name); _logger.Log("*** {0} ***", Description); TestCore(); }