public void TestClearBody() { AmqpNmsStreamMessageFacade amqpNmsStreamMessageFacade = CreateNewStreamMessageFacade(); // add some stuff amqpNmsStreamMessageFacade.Put(true); amqpNmsStreamMessageFacade.Put(false); // retrieve only some of it, leaving some unread Assert.AreEqual(true, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); amqpNmsStreamMessageFacade.Pop(); // clear amqpNmsStreamMessageFacade.ClearBody(); // add something else amqpNmsStreamMessageFacade.Put('c'); // check we can get it alone before another IOOBE (i.e position was reset, other contents cleared) Assert.AreEqual('c', amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); amqpNmsStreamMessageFacade.Pop(); Assert.Throws <MessageEOFException>(() => amqpNmsStreamMessageFacade.Peek()); }
public void TestResetPositionAfterPeekThrowsMEOFE() { global::Amqp.Message message = new global::Amqp.Message(); List <object> list = new List <object>(); list.Add(false); list.Add(true); message.BodySection = new AmqpSequence() { List = list }; AmqpNmsStreamMessageFacade amqpNmsStreamMessageFacade = CreateReceivedStreamMessageFacade(message); Assert.AreEqual(false, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); amqpNmsStreamMessageFacade.Pop(); Assert.AreEqual(true, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); amqpNmsStreamMessageFacade.Pop(); Assert.Throws <MessageEOFException>(() => amqpNmsStreamMessageFacade.Peek(), "expected exception to be thrown"); amqpNmsStreamMessageFacade.Reset(); Assert.AreEqual(false, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); amqpNmsStreamMessageFacade.Pop(); Assert.AreEqual(true, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); }
public void TestMessageCopy() { AmqpNmsStreamMessageFacade amqpNmsStreamMessageFacade = CreateNewStreamMessageFacade(); amqpNmsStreamMessageFacade.Put(true); amqpNmsStreamMessageFacade.Put("test"); amqpNmsStreamMessageFacade.Put(1); AmqpNmsStreamMessageFacade copy = amqpNmsStreamMessageFacade.Copy() as AmqpNmsStreamMessageFacade; Assert.IsNotNull(copy); Assert.AreEqual(true, copy.Peek()); copy.Pop(); Assert.AreEqual("test", copy.Peek()); copy.Pop(); Assert.AreEqual(1, copy.Peek()); copy.Pop(); }
public void TestRepeatedPeekAfterPopReturnsExpectedValue() { global::Amqp.Message message = new global::Amqp.Message(); List <object> list = new List <object>(); list.Add(false); list.Add(true); message.BodySection = new AmqpSequence() { List = list }; AmqpNmsStreamMessageFacade amqpNmsStreamMessageFacade = CreateReceivedStreamMessageFacade(message); Assert.AreEqual(false, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); amqpNmsStreamMessageFacade.Pop(); Assert.AreEqual(true, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); }
public void TestRepeatedPeekReturnsExpectedValue() { global::Amqp.Message message = new global::Amqp.Message(); List <object> list = new List <object>(); list.Add(false); list.Add(true); message.BodySection = new AmqpSequence() { List = list }; AmqpNmsStreamMessageFacade amqpNmsStreamMessageFacade = CreateReceivedStreamMessageFacade(message); Assert.True(amqpNmsStreamMessageFacade.HasBody(), "Message should report that it contains a body"); Assert.AreEqual(false, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); Assert.AreEqual(false, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); }
public void TestPeekUsingReceivedMessageWithAmqpValueBodyReturnsExpectedValue() { global::Amqp.Message message = new global::Amqp.Message(); List <object> list = new List <object>(); list.Add(false); message.BodySection = new AmqpValue() { Value = list }; AmqpNmsStreamMessageFacade amqpNmsStreamMessageFacade = CreateReceivedStreamMessageFacade(message); Assert.AreEqual(false, amqpNmsStreamMessageFacade.Peek(), "Unexpected value retrieved"); }
public void TestPeekWithNewMessageToSendThrowsMEOFE() { AmqpNmsStreamMessageFacade amqpNmsStreamMessageFacade = CreateNewStreamMessageFacade(); Assert.Throws <MessageEOFException>(() => amqpNmsStreamMessageFacade.Peek()); }