public void TestWriteStringReadLegal() { NmsStreamMessage streamMessage = factory.CreateStreamMessage(); string integralValue = Convert.ToString(byte.MaxValue); streamMessage.WriteString(integralValue); streamMessage.Reset(); AssertGetStreamEntryEquals <string>(streamMessage, true, integralValue); AssertGetStreamEntryEquals <bool>(streamMessage, true, false); AssertGetStreamEntryEquals <byte>(streamMessage, true, byte.MaxValue); streamMessage.ClearBody(); integralValue = Convert.ToString(short.MaxValue); streamMessage.WriteString(integralValue); streamMessage.Reset(); AssertGetStreamEntryEquals <short>(streamMessage, true, short.MaxValue); streamMessage.ClearBody(); integralValue = Convert.ToString(int.MaxValue); streamMessage.WriteString(integralValue); streamMessage.Reset(); AssertGetStreamEntryEquals <int>(streamMessage, true, int.MaxValue); streamMessage.ClearBody(); integralValue = Convert.ToString(long.MaxValue); streamMessage.WriteString(integralValue); streamMessage.Reset(); AssertGetStreamEntryEquals <long>(streamMessage, true, long.MaxValue); streamMessage.ClearBody(); string fpValue = Convert.ToString(float.MaxValue, CultureInfo.InvariantCulture); streamMessage.WriteString(fpValue); streamMessage.Reset(); AssertGetStreamEntryEquals <float>(streamMessage, true, float.Parse(fpValue)); // TODO: make following pass //AssertGetStreamEntryEquals<double>(streamMessage, true, double.Parse(fpValue)); }
public void TestClearBodyAppliesCorrectState() { NmsStreamMessage streamMessage = factory.CreateStreamMessage(); streamMessage.WriteObject(2); streamMessage.ClearBody(); Assert.False(streamMessage.IsReadOnlyBody); streamMessage.WriteObject(2); Assert.Throws <MessageNotReadableException>(() => streamMessage.ReadObject()); }
public void TestClearBodyOnNewMessageRemovesExistingValues() { NmsStreamMessage streamMessage = factory.CreateStreamMessage(); streamMessage.WriteBoolean(true); streamMessage.ClearBody(); streamMessage.WriteBoolean(false); streamMessage.Reset(); // check we get only the value added after the clear Assert.False(streamMessage.ReadBoolean(), "expected value added after the clear"); Assert.Throws <MessageEOFException>(() => streamMessage.ReadBoolean(), "Expected exception to be thrown"); }