public async Task Multiple_Threads_Send_To_One_Responder_Works(object configuration) { // Arrange var sut = new RqRep((SocketConfiguration)configuration); sut.Respond <Request, Response>(rq => new Response { ResponseNumber = rq.RequestNumber }); var input_output_Tuples = new List <(int, int)>(); var taskList = new List <Task>() { DoMultipleRequestAsync(sut, 1, input_output_Tuples), DoMultipleRequestAsync(sut, 2, input_output_Tuples), DoMultipleRequestAsync(sut, 3, input_output_Tuples), }; // Act await Task.WhenAll(taskList); // Assert foreach (var(_in, _out) in input_output_Tuples) { Assert.Equal(_in, _out); } sut.Dispose(); }
public async Task SimpleRequestAndReply_Fails_when_factory_throws_Exception_But_still_gets_an_answer(object configuration) { // Arrange var sut = new RqRep((SocketConfiguration)configuration); sut.Respond <Request, Response>(rq => throw new TimeoutException()); // Act var xtResult = await sut.RequestAsync <Request, Response>(new Request { RequestNumber = 42 }); // Assert Assert.False(xtResult.IsSuccess); Assert.NotNull(xtResult.Exception); sut.Dispose(); }
public async Task SimpleRequestAndReply_InProc() { // Arrange var sut = new RqRep(new ConfigurationTestData().GetSocketConfigInProc); sut.Respond <Request, Response>(rq => new Response { ResponseNumber = rq.RequestNumber }); // Act var xtResult = await sut.RequestAsync <Request, Response>(new Request { RequestNumber = 42 }); // Assert Assert.True(xtResult.IsSuccess); Assert.Equal(42, xtResult.GetResult().ResponseNumber); sut.Dispose(); }
public void Dispose() { _rqRep.Dispose(); _pubSub.Dispose(); _sendReceive.Dispose(); }