Exemplo n.º 1
0
 public override void Run()
 {
     try
     {
         DomainSocket client = preConnectedSockets != null ? preConnectedSockets[1] : DomainSocket
                               .Connect(TestPath);
         TestDomainSocket.WriteStrategy writer = System.Activator.CreateInstance(writeStrategyClass
                                                                                 );
         writer.Init(client);
         writer.Write(clientMsg1);
         TestDomainSocket.ReadStrategy reader = System.Activator.CreateInstance(readStrategyClass
                                                                                );
         reader.Init(client);
         byte[] in1 = new byte[serverMsg1.Length];
         reader.ReadFully(in1, 0, in1.Length);
         Assert.True(Arrays.Equals(serverMsg1, in1));
         OutputStream clientOutputStream = client.GetOutputStream();
         clientOutputStream.Write(clientMsg2);
         client.Close();
     }
     catch (Exception e)
     {
         threadResults.AddItem(e);
     }
     threadResults.AddItem(new TestDomainSocket.Success());
 }
Exemplo n.º 2
0
            public override void Run()
            {
                DomainSocket conn = null;

                try
                {
                    conn = preConnectedSockets != null ? preConnectedSockets[0] : serv.Accept();
                    byte[] in1 = new byte[clientMsg1.Length];
                    TestDomainSocket.ReadStrategy reader = System.Activator.CreateInstance(readStrategyClass
                                                                                           );
                    reader.Init(conn);
                    reader.ReadFully(in1, 0, in1.Length);
                    Assert.True(Arrays.Equals(clientMsg1, in1));
                    TestDomainSocket.WriteStrategy writer = System.Activator.CreateInstance(writeStrategyClass
                                                                                            );
                    writer.Init(conn);
                    writer.Write(serverMsg1);
                    InputStream connInputStream = conn.GetInputStream();
                    int         in2             = connInputStream.Read();
                    Assert.Equal((int)clientMsg2, in2);
                    conn.Close();
                }
                catch (Exception e)
                {
                    threadResults.AddItem(e);
                    NUnit.Framework.Assert.Fail(e.Message);
                }
                threadResults.AddItem(new TestDomainSocket.Success());
            }