Added test for server stopping and starting again.
Added test for client connecting after it has been closed. Fixed backlog. Rework of CI to ignore the WPF client.
This commit is contained in:
Родитель
04cd6e9c70
Коммит
4165f96c90
|
@ -1,2 +1,8 @@
|
|||
language: csharp
|
||||
solution: ./src/DtronixMessageQueue.sln
|
||||
install:
|
||||
- nuget install xunit.runners -Version 1.9.2 -OutputDirectory testrunner
|
||||
before_script:
|
||||
- nuget restore ./src/DtronixMessageQueue.sln
|
||||
script:
|
||||
- xbuild /p:Configuration=Release ./src/DtronixMessageQueue/DtronixMessageQueue.csproj
|
||||
- xbuild /p:Configuration=Release ./src/DtronixMessageQueue.Tests/DtronixMessageQueue.Tests.csproj
|
||||
|
|
|
@ -323,5 +323,40 @@ namespace DtronixMessageQueue.Tests.Mq
|
|||
throw new Exception("Socket did not timeout.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Client_reconnects_after_close()
|
||||
{
|
||||
int connected_times = 0;
|
||||
Server.Start();
|
||||
|
||||
Client.Connected += (sender, args) =>
|
||||
{
|
||||
if (++connected_times == 2)
|
||||
{
|
||||
TestStatus.Set();
|
||||
}
|
||||
Client.Close();
|
||||
|
||||
};
|
||||
Client.Closed += (sender, args) =>
|
||||
{
|
||||
if (connected_times < 2)
|
||||
{
|
||||
Client.Connect();
|
||||
}
|
||||
};
|
||||
|
||||
Client.Connect();
|
||||
|
||||
|
||||
|
||||
TestStatus.Wait(new TimeSpan(0, 0, 0, 0, 2000));
|
||||
|
||||
if (TestStatus.IsSet == false)
|
||||
{
|
||||
throw new TimeoutException("Test timed out.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -129,7 +129,7 @@ namespace DtronixMessageQueue.Tests.Mq
|
|||
client.Connect();
|
||||
|
||||
|
||||
TestStatus.Wait(new TimeSpan(0, 0, 0, 0, 10000));
|
||||
TestStatus.Wait(new TimeSpan(0, 0, 0, 0, 1000));
|
||||
|
||||
if (TestStatus.IsSet == false)
|
||||
{
|
||||
|
@ -141,6 +141,47 @@ namespace DtronixMessageQueue.Tests.Mq
|
|||
throw invalidClosException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Server_restarts_after_stop()
|
||||
{
|
||||
int connected_times = 0;
|
||||
Server.Start();
|
||||
|
||||
Client.Connected += (sender, args) =>
|
||||
{
|
||||
Server.Stop();
|
||||
Client.Close();
|
||||
if (++connected_times == 2)
|
||||
{
|
||||
TestStatus.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
Server.Start();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Client.Closed += (sender, args) =>
|
||||
{
|
||||
if (connected_times < 2)
|
||||
{
|
||||
Client.Connect();
|
||||
}
|
||||
};
|
||||
|
||||
Client.Connect();
|
||||
|
||||
|
||||
|
||||
TestStatus.Wait(new TimeSpan(0, 0, 0, 0, 2000));
|
||||
|
||||
if (TestStatus.IsSet == false)
|
||||
{
|
||||
throw new TimeoutException("Test timed out.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ namespace DtronixMessageQueue.Socket
|
|||
MainSocket.Bind(localEndPoint);
|
||||
|
||||
// start the server with a listen backlog.
|
||||
MainSocket.Listen(1);
|
||||
MainSocket.Listen(Config.ListenerBacklog);
|
||||
|
||||
// post accepts on the listening socket
|
||||
StartAccept(null);
|
||||
|
|
Загрузка…
Ссылка в новой задаче