public void WhenSendingDuplicateMessageTwiceWillGetItOnlyOnce() { var msg = new Message { Id = MessageId.GenerateRandom(), Queue = "h", Data = Encoding.Unicode.GetBytes("hello"), SentAt = DateTime.Now }; for (int i = 0; i < 2; i++) { var sender = new Sender(ObjectMother.Logger()) { Destination = new Endpoint("localhost", 23456), Messages = new[] { msg, }, }; try { sender.Send().Wait(); } catch (Exception) { //don't care if the sender throws on 2nd round } } using (var tx = new TransactionScope()) { var message = queueManager.Receive("h", null); "hello".ShouldEqual(Encoding.Unicode.GetString(message.Data)); tx.Complete(); } using (var tx = new TransactionScope()) { Assert.Throws<TimeoutException>(() => queueManager.Receive("h", null, TimeSpan.Zero)); tx.Complete(); } }
public void Setup() { _logger = new RecordingLogger(); wasSuccessful = false; error = null; sender = new Sender(_logger) { Destination = new Endpoint("localhost", 23456), Messages = new[] { new Message { Data = new byte[] {1, 2, 4}, Id = MessageId.GenerateRandom(), Queue = "ag", SentAt = new DateTime(2004, 4, 4) }, }, Success = () => { wasSuccessful = true; }, }; }