public void client_receives_both_messages()
        {
            var pipe1 = Guid.NewGuid().ToString();
            var pipe2 = Guid.NewGuid().ToString();
            var pipe3 = Guid.NewGuid().ToString();
            using (var server1 = new PipeServer(pipe1))
            {
                using (var server2 = new PipeServer(pipe2))
                {
                    using (var junction = new PipeJunction(pipe3))
                    {
                        junction.Combine(pipe1);
                        junction.Combine(pipe2);
                        server1.Send("Message from server 1");
                        server2.Send("Message from server 2");

                        var messages = new List<string>();
                        var client = new PipeClient();
                        new System.Threading.Thread(() => client.Listen(pipe3, (m) => messages.Add(m))).Start();
                        Timeout.AfterTwoSeconds().IfNot(() => messages.Count == 2);
                        Assert.That(messages.Count, Is.EqualTo(2));
                    }
                }
            }
        }
 public void the_client_receives_it()
 {
     var pipeName = Guid.NewGuid().ToString();
     var client = new PipeClient();
     using (var server = new PipeServer(pipeName))
     {
         string receivedMessage = null;
         new System.Threading.Thread(() => client.Listen(pipeName, (m) => receivedMessage = m)).Start();
         server.Send("message sent by server");
         Timeout.AfterTwoSeconds().IfNot(() => receivedMessage != null);
         Assert.That(receivedMessage, Is.EqualTo("message sent by server"));
     }
 }
Пример #3
0
 public IEnumerable<TestResult> Run(bool startLogger, Plugin plugin, string id, RunSettings settings)
 {
     if (startLogger)
         Logger.SetLogger(new ConsoleLogger());
     IEnumerable<TestResult> resultSet = null;
     var directories = new List<string>();
     directories.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
     directories.Add(Path.GetDirectoryName(settings.Assembly.Assembly));
     directories.Add(Path.GetDirectoryName(plugin.Assembly));
     using (var resolver = new AssemblyResolver(directories.ToArray()))
     {
         Logger.Write("About to create plugin {0} in {1} for {2}", plugin.Type, plugin.Assembly, id);
         var runner = getRunner(plugin);
         var currentDirectory = Environment.CurrentDirectory;
         try
         {
             if (runner == null)
                 return _results;
             using (var server = new PipeServer(settings.PipeName))
             {
                 Logger.Write("Matching plugin identifier ({0}) to test identifier ({1})", runner.Identifier, id);
                 if (!runner.Identifier.ToLower().Equals(id.ToLower()) && !id.ToLower().Equals("any"))
                     return _results;
                 Logger.Write("Checking whether assembly contains tests for {0}", id);
                 if (!settings.Assembly.IsVerified && !runner.ContainsTestsFor(settings.Assembly.Assembly))
                     return _results;
                 Logger.Write("Initializing channel");
                 runner.SetLiveFeedbackChannel(new TestFeedbackProvider(server));
                 var newCurrent = Path.GetDirectoryName(settings.Assembly.Assembly);
                 Logger.Write("Setting current directory to " + newCurrent);
                 Environment.CurrentDirectory = newCurrent;
                 Logger.Write("Starting test run");
                 resultSet = runner.Run(settings);
             }
         }
         catch
         {
             throw;
         }
         finally
         {
             Environment.CurrentDirectory = currentDirectory;
         }
     }
     return resultSet;
 }
 public TestFeedbackProvider(PipeServer channel)
 {
     _channel = channel;
 }
Пример #5
0
 public TestFeedbackProvider(PipeServer channel)
 {
     _channel = channel;
 }