контекстный вызов работает и передача объектов по сети тоже
This commit is contained in:
+54
-10
@@ -1,6 +1,9 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using mROA.Implementation;
|
||||
using Newtonsoft.Json;
|
||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||
|
||||
namespace mROA.Test;
|
||||
|
||||
@@ -11,9 +14,9 @@ public class Tests
|
||||
private IExecuteModule _executeModule;
|
||||
private IMethodRepository _methodRepository;
|
||||
private IContextRepository _contextRepository;
|
||||
|
||||
|
||||
private ITestController _testController;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -25,9 +28,9 @@ public class Tests
|
||||
var repo2 = new ContextRepository();
|
||||
repo2.FillSingletons(Assembly.GetExecutingAssembly());
|
||||
_contextRepository = repo2;
|
||||
|
||||
_executeModule = new PrepairedExecutionModule(_methodRepository, _serialisationModule, _contextRepository);
|
||||
|
||||
_executeModule = new PrepairedExecutionModule(_methodRepository, _serialisationModule, _contextRepository);
|
||||
TransmissionConfig.DefaultContextRepository = _contextRepository;
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -41,7 +44,7 @@ public class Tests
|
||||
"CommandId": 2
|
||||
}
|
||||
""");
|
||||
Assert.Pass(sw.ElapsedMilliseconds.ToString());
|
||||
Assert.Pass(_interactionModule.OutputBuffer.Last());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -55,18 +58,18 @@ public class Tests
|
||||
}
|
||||
""");
|
||||
while (_interactionModule.OutputBuffer.Count != 2) ;
|
||||
|
||||
Assert.Pass(sw.ElapsedMilliseconds.ToString());
|
||||
|
||||
Assert.Pass(_interactionModule.OutputBuffer.Last());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void MethodRegistrationTest()
|
||||
{
|
||||
var repo = new MethodRepository();
|
||||
repo.CollectForAssembly(Assembly.GetExecutingAssembly());
|
||||
Assert.That(repo.GetMethods().ToList().Count == 4);
|
||||
Assert.That(repo.GetMethods().ToList().Count == 5);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ContextSupplyTest()
|
||||
{
|
||||
@@ -76,4 +79,45 @@ public class Tests
|
||||
singleObject.B();
|
||||
Assert.That(singleObject.B() == 6);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TransmissionTest()
|
||||
{
|
||||
_interactionModule.PassCommand(132, """
|
||||
{
|
||||
"CommandId": 4
|
||||
}
|
||||
""");
|
||||
var response =
|
||||
JsonSerializer.Deserialize<TransmittedSharedObject<IContextRepository>>(
|
||||
JsonSerializer.Deserialize<FinalCommandExecution>(_interactionModule.OutputBuffer.Last())
|
||||
?.Result.ToString()
|
||||
);
|
||||
|
||||
_interactionModule.PassCommand(132,
|
||||
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }));
|
||||
|
||||
var firstFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result")
|
||||
.GetInt32();
|
||||
|
||||
_interactionModule.PassCommand(132,
|
||||
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 4, ObjectId = response.ContextId }));
|
||||
|
||||
response =
|
||||
JsonSerializer.Deserialize<TransmittedSharedObject<IContextRepository>>(
|
||||
JsonSerializer.Deserialize<FinalCommandExecution>(_interactionModule.OutputBuffer.Last())
|
||||
?.Result.ToString()
|
||||
);
|
||||
|
||||
_interactionModule.PassCommand(132,
|
||||
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }));
|
||||
_interactionModule.PassCommand(132,
|
||||
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }));
|
||||
|
||||
var secondFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result")
|
||||
.GetInt32();
|
||||
|
||||
Assert.That(firstFull == 456789 && secondFull == 6);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user