//todo deactivated as it crashed the test framework [TestMethod] public void OutgoingMessageIsResetOnSocketReset() { const string hostname = "127.0.0.1"; const int port = 10100; const string connectionIdentifier = "1"; var server = new SingleConnectionServer(); server.StartListening(); var engine = ExecutionEngineFactory.StartNew(new InMemoryStorageEngine()); engine.Schedule(() => { var unackedMessageQueue = new OutgoingMessageQueue(); var deliverer = new OutgoingMessageDeliverer(hostname, port, connectionIdentifier, unackedMessageQueue); Roots.Entangle(deliverer); Roots.Entangle(unackedMessageQueue); deliverer.Send("HELLO WORLD".GetUtf8Bytes()); }); Thread.Sleep(1_000); server.DisposeConnectedSocket(); Thread.Sleep(1_000); server.GetNodeIdentifier().ShouldBe("1"); server.GetReceivedMessages().Count.ShouldBe(2); }
public void OutgoingConnectionSendsMessageSuccessfully() { const string hostname = "127.0.0.1"; const int port = 10100; const string connectionIdentifier = "1"; var server = new SingleConnectionServer(); server.StartListening(); var engine = ExecutionEngineFactory.StartNew(new InMemoryStorageEngine()); engine.Schedule(() => { var unackedMessageQueue = new OutgoingMessageQueue(); var deliverer = new OutgoingMessageDeliverer(hostname, port, connectionIdentifier, unackedMessageQueue); Roots.Entangle(deliverer); Roots.Entangle(unackedMessageQueue); deliverer.Send("HELLO WORLD".GetUtf8Bytes()); }); Thread.Sleep(1_000); server.GetNodeIdentifier().ShouldBe("1"); server.GetReceivedMessages()[0].Item2.ShouldBe("HELLO WORLD"); var unackeds = engine.Schedule(() => { var q = Roots.Resolve <OutgoingMessageQueue>(); return(q.GetSyncedUnackedMessages().ToArray()); }).Result; unackeds.Length.ShouldBe(1); unackeds[0].Item1.ShouldBe(0); unackeds[0].Item2.Array.ToUtf8String().ShouldBe("HELLO WORLD"); server.AckUntil(0); Thread.Sleep(1_000); unackeds = engine.Schedule(() => { var q = Roots.Resolve <OutgoingMessageQueue>(); return(q.GetSyncedUnackedMessages().ToArray()); }).Result; unackeds.Length.ShouldBe(0); }