Ejemplo n.º 1
0
        public virtual void setup()
        {
            channel = new Mock <INetworkChannel>();

            channel.Setup(ch => ch.Send(It.IsAny <string>())).Callback((string message) =>
            {
                sentMessages.Add(message);
            });

            sentMessages = new List <string>();

            var channelFactory = new Mock <IChannelFactory>();

            channelFactory.Setup(f => f.Create()).Returns(channel.Object);

            adapter = new DiscoveryAdapter(channelFactory.Object);
        }
Ejemplo n.º 2
0
        public ITestRunner Create(LaunchOptions options)
        {
            string testAssemblyPath = options.DotNet.Project;

            if (testAssemblyPath == null)
            {
                throw new DotNetTestNSpecException("Command line arguments must include path of test project assembly");
            }

            var controllerProxy = proxyFactory.Create(testAssemblyPath);

            if (!options.DotNet.Port.HasValue)
            {
                return(new ConsoleRunner(testAssemblyPath, controllerProxy, options.NSpec));
            }

            ITestRunner runner;

            if (options.DotNet.List)
            {
                var adapter = new DiscoveryAdapter(channelFactory);

                runner = new DiscoveryRunner(testAssemblyPath, controllerProxy, adapter);
            }
            else if (options.DotNet.WaitCommand)
            {
                var adapter = new ExecutionAdapter(channelFactory);

                runner = new ExecutionRunner(testAssemblyPath, controllerProxy, adapter);
            }
            else
            {
                throw new DotNetTestNSpecException("Design-time command line argument must include either list or wait command options");
            }

            return(runner);
        }