ServerTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Networking.Tests ServerTests

Namespace: DeltaEngine.Networking.Tests
Assembly: DeltaEngine.Networking.Tests (in DeltaEngine.Networking.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class ServerTests

The ServerTests type exposes the following members.

Constructors

  NameDescription
Public methodServerTests
Initializes a new instance of the ServerTests class
Top
Methods

  NameDescription
Public methodConnectClient
Public methodDisconnectClient
Public methodDisconnectServer
Public methodInitiallyNoClients
Public methodListenForClients
Public methodSetUp
Top
Examples

[Test]
public void ListenForClients()
{
    server.Start(800);
    Assert.IsTrue(server.IsRunning);
}
[Test]
public void InitiallyNoClients()
{
    Assert.AreEqual(0, server.ListenPort);
    Assert.AreEqual(0, server.NumberOfConnectedClients);
}
[Test]
public void ConnectClient()
{
    bool didClientConnect = false;
    server.ClientConnected += client => didClientConnect = true;
    CreateConnectedClient();
    Assert.AreEqual(1, server.NumberOfConnectedClients);
    Assert.IsTrue(didClientConnect);
}
[Test]
public void DisconnectClient()
{
    bool didClientDisconnect = false;
    server.ClientDisconnected += c => didClientDisconnect = true;
    var client = CreateConnectedClient();
    client.Dispose();
    Assert.IsTrue(didClientDisconnect);
}
[Test]
public void DisconnectServer()
{
    var client = CreateConnectedClient();
    server.Dispose();
    Assert.IsFalse(client.IsConnected);
}
See Also