예제 #1
0
        /// <summary>
        /// Example test that performs a connect, then disconnect.
        /// All tests must have the same signature of returning an async Task
        /// and taking in a ServiceTestDriver as a parameter.
        /// </summary>
        public async Task ConnectDisconnectTest(ServiceTestDriver driver)
        {
            var connectParams = new ConnectParams();

            connectParams.OwnerUri                      = "file";
            connectParams.Connection                    = new ConnectionDetails();
            connectParams.Connection.ServerName         = "localhost";
            connectParams.Connection.AuthenticationType = "Integrated";

            var result = await driver.SendRequest(ConnectionRequest.Type, connectParams);

            if (result)
            {
                await driver.WaitForEvent(ConnectionCompleteNotification.Type);

                var disconnectParams = new DisconnectParams();
                disconnectParams.OwnerUri = "file";
                var result2 = await driver.SendRequest(DisconnectRequest.Type, disconnectParams);

                if (result2)
                {
                    Console.WriteLine("success");
                }
            }
        }
예제 #2
0
        internal static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Microsoft.SqlTools.ServiceLayer.TestDriver.exe <service host executable> [tests]" + Environment.NewLine +
                                  "    <service host executable> is the path to the Microsoft.SqlTools.ServiceLayer.exe executable" + Environment.NewLine +
                                  "    [tests] is a space-separated list of tests to run." + Environment.NewLine +
                                  "            They are qualified within the Microsoft.SqlTools.ServiceLayer.TestDriver.Tests namespace");
                Environment.Exit(0);
            }

            Task.Run(async() =>
            {
                var serviceHostExecutable = args[0];
                var tests = args.Skip(1);

                foreach (var test in tests)
                {
                    ServiceTestDriver driver = null;

                    try
                    {
                        driver = new ServiceTestDriver(serviceHostExecutable);

                        var className  = test.Substring(0, test.LastIndexOf('.'));
                        var methodName = test.Substring(test.LastIndexOf('.') + 1);

                        var type              = Type.GetType("Microsoft.SqlTools.ServiceLayer.TestDriver.Tests." + className);
                        var typeInstance      = Activator.CreateInstance(type);
                        MethodInfo methodInfo = type.GetMethod(methodName);

                        await driver.Start();
                        Console.WriteLine("Running test " + test);
                        await(Task) methodInfo.Invoke(typeInstance, new object[] { driver });
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                    finally
                    {
                        if (driver != null)
                        {
                            await driver.Stop();
                        }
                    }
                }
            }).Wait();
        }
 public TestServiceDriverProvider()
 {
     Driver = new ServiceTestDriver(TestRunner.Instance.ExecutableFilePath);
     Driver.Start().Wait();
     this.isRunning = true;
 }
 public TestServiceDriverProvider()
 {
     Driver = new ServiceTestDriver();
     Driver.Start().Wait();
     this.isRunning = true;
 }
예제 #5
0
 public TestHelper()
 {
     Driver = new ServiceTestDriver();
     Driver.Start().Wait();
     this.isRunning = true;
 }