示例#1
0
 public Int32 CreateConnection(String server, UInt16 port)
 {
     ConnectionProvider connection = new ConnectionProvider(server, port);
     connection.Connect();
     connection.MessageArrived += new ConnectionProvider.MessageArrivedEventHandler(MessageArrived);
     connections.Add(connection);
     return connections.Count;
 }
示例#2
0
 public void CorrectConnect()
 {
     ConnectionProvider provider = new ConnectionProvider();
     provider.Server = "localhost";
     provider.Port = 6667;
     provider.Connect();
     Assert.AreEqual(1, server.Clients.Count);
 }
示例#3
0
 public void IsConnectedAndConnect()
 {
     ConnectionProvider provider = new ConnectionProvider();
     Assert.IsFalse(provider.IsConnected, "IsConnected should be false");
     provider.Server = "localhost";
     provider.Port = 6667;
     provider.Connect();
     Assert.IsTrue(provider.IsConnected, "IsConnected should be true");
 }
示例#4
0
 public void MessageArrivedEvent()
 {
     ConnectionProvider provider = new ConnectionProvider();
     provider.MessageArrived += new ConnectionProvider.MessageArrivedEventHandler(MessageArrivedEvent_MessageArrived);
 }
示例#5
0
 public void IsConnectedProperty()
 {
     ConnectionProvider provider = new ConnectionProvider();
     Assert.IsFalse(provider.IsConnected, "IsConnected should be false");
 }
示例#6
0
 public void ConnectThrowsExceptionForServer()
 {
     ConnectionProvider provider = new ConnectionProvider();
     provider.Connect();
 }
示例#7
0
 public void ConstructorWithServerAndPort()
 {
     ConnectionProvider provider = new ConnectionProvider("localhost", 6667);
     Assert.AreEqual("localhost", provider.Server, "Server property is not ok");
     Assert.AreEqual(6667, provider.Port, "Port property is not ok");
 }
示例#8
0
 public void TerminateConnection()
 {
     try
     {
         ConnectionProvider provider = new ConnectionProvider("localhost", 6667);
         provider.Connect();
         provider.Disconnect();
     }
     catch
     {
         Assert.Fail();
     }
 }
示例#9
0
 public void ConnectThrowsExceptionForPort()
 {
     ConnectionProvider provider = new ConnectionProvider();
     provider.Server = "localhost";
     provider.Connect();
 }
示例#10
0
 public void ServerProperty()
 {
     ConnectionProvider provider = new ConnectionProvider();
     provider.Server = "localhost";
     Assert.AreEqual("localhost", provider.Server, "Server property is not set right");
 }
示例#11
0
 public void SendNullString()
 {
     ConnectionProvider provider = new ConnectionProvider("localhost", 6667);
     provider.Connect();
     try
     {
         provider.SendMessage(null);
         Assert.Fail("Must throw exception");
     }
     catch(ArgumentNullException exception)
     {
         Assert.AreEqual("message", exception.ParamName, "Param message must be null");
     }
     catch
     {
         Assert.Fail("Invalid exception type");
     }
 }
示例#12
0
 public void SendMessage()
 {
     ConnectionProvider provider = new ConnectionProvider("localhost", 6667);
     provider.Connect();
     provider.SendMessage("Hello");
     Assert.AreEqual("Hello", ((ServerConnectionHandler) server.Clients[0]).GetMessage());
 }
示例#13
0
 public void ReceiveMessage()
 {
     ConnectionProvider provider = new ConnectionProvider("localhost", 6667);
     //provider.MessageArrived += new ConnectionProvider.MessageArrivedEventHandler(ReceiveMessage_MessageArrived);
     provider.Connect();
     /*
     lock(this)
     {
         server.SendMessage("Hello");
         Monitor.Wait(this);
     }
     Assert.IsNotNull(eventArgs, "eventArgs is null");
     Assert.AreEqual("Hello", eventArgs.Message, "Invalid message");
     eventArgs = null;
     */
 }
示例#14
0
 public void PortProperty()
 {
     ConnectionProvider provider = new ConnectionProvider();
     provider.Port = 6667;
     Assert.AreEqual(6667, provider.Port, "Port property is not set right");
 }