переделывание тестов

This commit is contained in:
2025-02-05 10:58:50 +03:00
parent fd1eda2661
commit f51dd93c87
28 changed files with 407 additions and 325 deletions
+65 -66
View File
@@ -1,66 +1,65 @@
using System.Net;
using System.Net.Sockets;
using System.Text.Json;
using mROA.Implementation;
using mROA.Implementation.Test;
namespace mROA.Test;
public class StreamTest
{
private StreamBasedInteractionModule _interactionModule;
private StreamBasedFrontendInteractionModule _frontendInteractionModule;
private JsonFrontendSerialisationModule _frontendSerialisationModule;
private ISerialisationModule _serialisationModule;
private IExecuteModule _executeModule;
bool isTestNotFinished = true;
[SetUp]
public void Setup()
{
_interactionModule = new StreamBasedInteractionModule();
_serialisationModule = new JsonSerialisationModule(_interactionModule, new MockMethodRepository());
_executeModule = new MockExecModule();
_serialisationModule.SetExecuteModule(_executeModule);
_frontendInteractionModule = new StreamBasedFrontendInteractionModule();
_frontendSerialisationModule = new JsonFrontendSerialisationModule(_frontendInteractionModule);
Task.Run(() =>
{
TcpListener listener = new TcpListener(IPAddress.Loopback, 4567);
listener.Start();
var stream = listener.AcceptTcpClient().GetStream();
Console.WriteLine("Client connected");
_interactionModule.RegisterSourse(stream);
while (isTestNotFinished) ;
});
}
[Test]
public void StreamingTest()
{
var tcpClient = new TcpClient();
tcpClient.Connect(IPAddress.Loopback, 4567);
_frontendInteractionModule.ServerStream = tcpClient.GetStream();
var req = new DefaultCallRequest { CommandId = 1, ObjectId = -1 };
_frontendSerialisationModule.PostCallRequest(req);
var res = ((JsonElement)_frontendSerialisationModule.GetNextCommandExecution<FinalCommandExecution>(req.CallRequestId).GetAwaiter().GetResult().Result!).Deserialize<MockResult>();
isTestNotFinished = false;
Assert.That(res.A == "wqer" && res.B == 5);
}
[Test]
public void RemoteObjectTest()
{
}
}
// using System.Net;
// using System.Net.Sockets;
// using System.Text.Json;
// using mROA.Implementation;
//
// namespace mROA.Test;
//
// public class StreamTest
// {
// private StreamBasedInteractionModule _interactionModule;
// private StreamBasedFrontendInteractionModule _frontendInteractionModule;
// private JsonFrontendSerialisationModule _frontendSerialisationModule;
// private ISerialisationModule _serialisationModule;
// private IExecuteModule _executeModule;
// bool isTestNotFinished = true;
//
// [SetUp]
// public void Setup()
// {
// _interactionModule = new StreamBasedInteractionModule();
//
// _serialisationModule = new JsonSerialisationModule(_interactionModule, new MockMethodRepository());
//
// _executeModule = new MockExecModule();
// _serialisationModule.SetExecuteModule(_executeModule);
//
// _frontendInteractionModule = new StreamBasedFrontendInteractionModule();
// _frontendSerialisationModule = new JsonFrontendSerialisationModule(_frontendInteractionModule);
//
// Task.Run(() =>
// {
// TcpListener listener = new TcpListener(IPAddress.Loopback, 4567);
// listener.Start();
//
// var stream = listener.AcceptTcpClient().GetStream();
//
// Console.WriteLine("Client connected");
//
// _interactionModule.RegisterSourse(stream);
//
// while (isTestNotFinished) ;
// });
// }
//
// [Test]
// public void StreamingTest()
// {
// var tcpClient = new TcpClient();
// tcpClient.Connect(IPAddress.Loopback, 4567);
// _frontendInteractionModule.ServerStream = tcpClient.GetStream();
//
// var req = new DefaultCallRequest { CommandId = 1, ObjectId = -1 };
// _frontendSerialisationModule.PostCallRequest(req);
// var res = ((JsonElement)_frontendSerialisationModule
// .GetNextCommandExecution<FinalCommandExecution>(req.CallRequestId).GetAwaiter().GetResult().Result!)
// .Deserialize<MockResult>();
// isTestNotFinished = false;
// Assert.That(res.A == "wqer" && res.B == 5);
// }
//
// [Test]
// public void RemoteObjectTest()
// {
// }
// }