сетевой вызов метода работает
This commit is contained in:
+32
-4
@@ -1,28 +1,56 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
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;
|
||||
private IMethodRepository _methodRepository;
|
||||
private IContextRepository _contextRepository;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_interactionModule = new StreamBasedInteractionModule();
|
||||
|
||||
_serialisationModule = new JsonSerialisationModule(_interactionModule, _methodRepository);
|
||||
|
||||
_serialisationModule = new JsonSerialisationModule(_interactionModule, new MockMethodRepository());
|
||||
|
||||
_executeModule = new MockExecModule();
|
||||
_serialisationModule.SetExecuteModule(_executeModule);
|
||||
|
||||
_frontendInteractionModule = new StreamBasedFrontendInteractionModule();
|
||||
_frontendSerialisationModule = new JsonFrontendSerialisationModule(_frontendInteractionModule);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StreamingTest()
|
||||
{
|
||||
bool isTestNotFinished = true;
|
||||
Task.Run(() =>
|
||||
{
|
||||
TcpListener listener = new TcpListener(IPAddress.Loopback, 4567);
|
||||
listener.Start();
|
||||
|
||||
var stream = listener.AcceptTcpClient().GetStream();
|
||||
|
||||
Console.WriteLine("Client connected");
|
||||
|
||||
_interactionModule.RegisterClient(stream);
|
||||
|
||||
while (isTestNotFinished) ;
|
||||
});
|
||||
var tcpClient = new TcpClient();
|
||||
tcpClient.Connect(IPAddress.Loopback, 4567);
|
||||
_frontendInteractionModule.ServerStream = tcpClient.GetStream();
|
||||
|
||||
var req = new JsonCallRequest { CommandId = 1, ObjectId = -1 };
|
||||
_frontendSerialisationModule.PostCallRequest(req);
|
||||
var res =_frontendSerialisationModule.GetNextCommandExecution<FinalCommandExecution>(req.CallRequestId).Result;
|
||||
isTestNotFinished = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user