private static NinjectSelfHostBootstrapper CreateAndStartTestService(TestServiceConfiguration config, IKernel kernel)
        {
            var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
            {
                SendTimeout = TimeSpan.FromSeconds(10)
            };
            var address   = new Uri(BaseUrl, config.Id);
            var wcfConfig = NinjectWcfConfiguration.Create <DefaultTestService, NinjectServiceSelfHostFactory>(
                h => h.AddServiceEndpoint(typeof(ITestService), binding, address));

            var host = new NinjectSelfHostBootstrapper(() => kernel, wcfConfig);

            if (!kernel.GetAll <INinjectSelfHost>().Any())
            {
                throw new TestServiceException("Can't start test service because no instances of `INinjectSelfHost` are registered");
            }
            host.Start();
            return(host);
        }
        /// <summary>
        /// Start the xUnit WCF service and use a custom runner.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static IDisposable StartWithCustomRunner <T>(TestServiceConfiguration config)
            where T : ITestRunner
        {
            var kernel = GetKernel();

            kernel.Bind <ITestResultNotificationService>()
            .ToMethod(ctx => OperationContext.Current.GetCallbackChannel <ITestResultNotificationService>())
            //.WhenInjectedInto<DefaultTestRunner>()
            .InTransientScope();

            kernel.Bind <ITestRunner>()
            .To <DefaultTestRunner>()
            .WhenInjectedInto <T>()
            .InTransientScope();

            kernel.Bind <ITestRunner>()
            .To <T>()
            .WhenInjectedInto <DefaultTestService>()
            .InTransientScope();

            return(Start(config, kernel));
        }
 private static IDisposable Start(TestServiceConfiguration config, IKernel kernel)
 {
     Data = config.Data;
     return(CreateAndStartTestService(config, kernel));
 }
 /// <summary>
 /// Start the xUnit WCF service and use the default runner that simply executes the tests.
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static IDisposable StartWithDefaultRunner(TestServiceConfiguration config)
 {
     return(StartWithCustomRunner <DefaultTestRunner>(config));
 }