mirror of
https://github.com/pleonex/NitroDebugger.git
synced 2025-06-18 13:15:39 -04:00
Improve server connections in Unit Tests
Previously since in the TearDown it opened connections, it could leave some open connections. It was also trying to close twice the connections (TearDown and FixtureTearDown)
This commit is contained in:
parent
e9307a08d2
commit
7c144f9d34
@ -24,13 +24,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
using NUnit.Framework;
|
||||
using NitroDebugger;
|
||||
using NitroDebugger.RSP;
|
||||
@ -45,9 +39,9 @@ namespace UnitTests
|
||||
}
|
||||
|
||||
[TestFixtureSetUp]
|
||||
protected override void Setup()
|
||||
protected override void SetUp()
|
||||
{
|
||||
base.Setup();
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
@ -56,10 +50,16 @@ namespace UnitTests
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
protected override void OpenServer()
|
||||
{
|
||||
base.OpenServer();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
protected override void ResetServer()
|
||||
protected override void CloseServer()
|
||||
{
|
||||
base.ResetServer();
|
||||
base.CloseServer();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -25,13 +25,6 @@
|
||||
// SOFTWARE.
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using NitroDebugger.RSP;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using NitroDebugger;
|
||||
|
||||
namespace UnitTests
|
||||
@ -44,9 +37,9 @@ namespace UnitTests
|
||||
}
|
||||
|
||||
[TestFixtureSetUp]
|
||||
protected override void Setup()
|
||||
protected override void SetUp()
|
||||
{
|
||||
base.Setup();
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
@ -55,10 +48,16 @@ namespace UnitTests
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
protected override void OpenServer()
|
||||
{
|
||||
base.OpenServer();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
protected override void ResetServer()
|
||||
protected override void CloseServer()
|
||||
{
|
||||
base.ResetServer();
|
||||
base.CloseServer();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -43,27 +43,26 @@ namespace UnitTests
|
||||
Port = PortBase + index;
|
||||
}
|
||||
|
||||
protected virtual void Setup()
|
||||
protected virtual void SetUp()
|
||||
{
|
||||
this.Server = new TcpListener(IPAddress.Loopback, Port);
|
||||
this.Server.Start();
|
||||
|
||||
this.Client = new GdbClient();
|
||||
this.Client.Connection.Connect(Host, Port);
|
||||
|
||||
this.ServerClient = this.Server.AcceptTcpClient();
|
||||
this.ServerStream = this.ServerClient.GetStream();
|
||||
}
|
||||
|
||||
protected virtual void Dispose()
|
||||
{
|
||||
this.Client.Connection.Disconnect();
|
||||
if (this.ServerClient.Connected)
|
||||
this.ServerClient.Close();
|
||||
this.Server.Stop();
|
||||
}
|
||||
|
||||
protected virtual void ResetServer()
|
||||
protected virtual void OpenServer()
|
||||
{
|
||||
this.Client.Connection.Connect(Host, Port);
|
||||
this.ServerClient = this.Server.AcceptTcpClient();
|
||||
this.ServerStream = this.ServerClient.GetStream();
|
||||
}
|
||||
|
||||
protected virtual void CloseServer()
|
||||
{
|
||||
this.Client.Connection.Disconnect();
|
||||
if (this.ServerClient.Connected)
|
||||
@ -71,10 +70,6 @@ namespace UnitTests
|
||||
|
||||
while (this.Server.Pending())
|
||||
this.Server.AcceptTcpClient().Close();
|
||||
|
||||
this.Client.Connection.Connect(Host, Port);
|
||||
this.ServerClient = this.Server.AcceptTcpClient();
|
||||
this.ServerStream = this.ServerClient.GetStream();
|
||||
}
|
||||
|
||||
protected void SendPacket(string cmd, string args)
|
||||
|
@ -41,9 +41,9 @@ namespace UnitTests
|
||||
}
|
||||
|
||||
[TestFixtureSetUp]
|
||||
protected override void Setup()
|
||||
protected override void SetUp()
|
||||
{
|
||||
base.Setup();
|
||||
base.SetUp();
|
||||
manager = Client.Registers;
|
||||
}
|
||||
|
||||
@ -53,10 +53,16 @@ namespace UnitTests
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
protected override void OpenServer()
|
||||
{
|
||||
base.OpenServer();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
protected override void ResetServer()
|
||||
protected override void CloseServer()
|
||||
{
|
||||
base.ResetServer();
|
||||
base.CloseServer();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
Loading…
Reference in New Issue
Block a user