コード例 #1
0
		public void Cannot_deserialize_without_content_type()
		{
			var s1 = new SerializeTestClass
			{
				Number = 123,
				Text = "This is some text"
			};

			var frame = new StompFrame();
			frame.Serialize(s1);
			frame.Headers[StompHeader.ContentType] = "text/plain";

			try
			{
				frame.Deserialize();
				Assert.Fail("Expected exception");
			}
			catch (InvalidOperationException ex)
			{
				Assert.AreEqual("Cannot deserialize: content-type:text/plain", ex.Message);
			}
		}
コード例 #2
0
		public void Cannot_deserialize_without_clr_type()
		{
			var s1 = new SerializeTestClass
			{
				Number = 123,
				Text = "This is some text"
			};

			var frame = new StompFrame();
			frame.Serialize(s1);
			frame.Headers[StompHeader.NonStandard.ClrType] = null;

			try
			{
				frame.Deserialize();
				Assert.Fail("Expected exception");
			}
			catch (InvalidOperationException ex)
			{
				Assert.AreEqual("Cannot deserialize: no clr-type specified", ex.Message);
			}
		}
コード例 #3
0
		public void Serialize()
		{
			var s1 = new SerializeTestClass
			         	{
			         		Number = 123,
			         		Text = "This is some text"
			         	};

			var frame = new StompFrame();
			frame.Serialize(s1);

			var s2 = (SerializeTestClass)frame.Deserialize();
			Assert.IsNotNull(s2);
			Assert.AreEqual(s1.Number, s2.Number);
			Assert.AreEqual(s1.Text, s2.Text);
		}