diff options
| author | Aidan Skinner <aidan@apache.org> | 2009-12-03 23:55:48 +0000 |
|---|---|---|
| committer | Aidan Skinner <aidan@apache.org> | 2009-12-03 23:55:48 +0000 |
| commit | 43f0dea566c81bb72aea75b825bbd97ec5d1d950 (patch) | |
| tree | c8a33d349851bd6c231ec72546cddd39e9becb17 /dotnet/Qpid.Common.Tests | |
| parent | 4e76800d4d4a1599452c52b473ab5e2684160698 (diff) | |
| download | qpid-python-43f0dea566c81bb72aea75b825bbd97ec5d1d950.tar.gz | |
Fix eol style property
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@886998 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Common.Tests')
3 files changed, 415 insertions, 415 deletions
diff --git a/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs b/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs index 03ed999999..3e19508bac 100644 --- a/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs +++ b/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs @@ -1,85 +1,85 @@ -/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-using System;
-using System.Collections;
-using System.Text;
-using System.Threading;
-using NUnit.Framework;
-using Apache.Qpid.Collections;
-
-namespace Apache.Qpid.Collections.Tests
-{
- [TestFixture]
- public class TestConsumerProducerQueue
- {
- private ConsumerProducerQueue _queue;
-
- [SetUp]
- public void SetUp()
- {
- _queue = new ConsumerProducerQueue();
- }
-
- [Test]
- public void CanDequeueWithInifiniteWait()
- {
- Thread producer = new Thread(new ThreadStart(ProduceFive));
- producer.Start();
- for ( int i = 0; i < 5; i++ )
- {
- object item = _queue.Dequeue();
- Assert.IsNotNull(item);
- }
- }
-
- [Test]
- public void ReturnsNullOnDequeueTimeout()
- {
- // queue is empty
- Assert.IsNull(_queue.Dequeue(500));
- }
-
- [Test]
- public void DequeueTillEmpty()
- {
- _queue.Enqueue(1);
- _queue.Enqueue(2);
- _queue.Enqueue(3);
- Assert.AreEqual(1, _queue.Dequeue());
- Assert.AreEqual(2, _queue.Dequeue());
- Assert.AreEqual(3, _queue.Dequeue());
- // no messages in queue, will timeout
- Assert.IsNull(_queue.Dequeue(500));
- }
-
-
- private void ProduceFive()
- {
- Thread.Sleep(1000);
- _queue.Enqueue("test item 1");
- _queue.Enqueue("test item 2");
- _queue.Enqueue("test item 3");
- Thread.Sleep(0);
- _queue.Enqueue("test item 4");
- _queue.Enqueue("test item 5");
- }
- }
-}
+/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +using System; +using System.Collections; +using System.Text; +using System.Threading; +using NUnit.Framework; +using Apache.Qpid.Collections; + +namespace Apache.Qpid.Collections.Tests +{ + [TestFixture] + public class TestConsumerProducerQueue + { + private ConsumerProducerQueue _queue; + + [SetUp] + public void SetUp() + { + _queue = new ConsumerProducerQueue(); + } + + [Test] + public void CanDequeueWithInifiniteWait() + { + Thread producer = new Thread(new ThreadStart(ProduceFive)); + producer.Start(); + for ( int i = 0; i < 5; i++ ) + { + object item = _queue.Dequeue(); + Assert.IsNotNull(item); + } + } + + [Test] + public void ReturnsNullOnDequeueTimeout() + { + // queue is empty + Assert.IsNull(_queue.Dequeue(500)); + } + + [Test] + public void DequeueTillEmpty() + { + _queue.Enqueue(1); + _queue.Enqueue(2); + _queue.Enqueue(3); + Assert.AreEqual(1, _queue.Dequeue()); + Assert.AreEqual(2, _queue.Dequeue()); + Assert.AreEqual(3, _queue.Dequeue()); + // no messages in queue, will timeout + Assert.IsNull(_queue.Dequeue(500)); + } + + + private void ProduceFive() + { + Thread.Sleep(1000); + _queue.Enqueue("test item 1"); + _queue.Enqueue("test item 2"); + _queue.Enqueue("test item 3"); + Thread.Sleep(0); + _queue.Enqueue("test item 4"); + _queue.Enqueue("test item 5"); + } + } +} diff --git a/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs b/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs index ab4cb4409c..23cb71c9f8 100644 --- a/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs +++ b/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs @@ -1,270 +1,270 @@ -/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-using System;
-using NUnit.Framework;
-using Apache.Qpid.Buffer;
-using Apache.Qpid.Framing;
-
-namespace Apache.Qpid.Framing.Tests
-{
- [TestFixture]
- public class TestAMQType
- {
-
- #region LONG_STRING tests
- [Test]
- public void LONG_STRING_ReadWrite()
- {
- AMQType type = AMQType.LONG_STRING;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const string VALUE = "simple string 1";
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // LONG_STRING tests
-
- #region UINT32 tests
- [Test]
- public void UINT32_CanGetEncodingSize()
- {
- AMQType type = AMQType.UINT32;
- Assert.AreEqual(4, type.GetEncodingSize(1234443));
- }
-
- [Test]
- public void UINT32_ToNativeValue()
- {
- AMQType type = AMQType.UINT32;
- Assert.AreEqual(1, type.ToNativeValue(1));
- Assert.AreEqual(1, type.ToNativeValue((short)1));
- Assert.AreEqual(1, type.ToNativeValue((byte)1));
- Assert.AreEqual(1, type.ToNativeValue("1"));
-
- try
- {
- Assert.AreEqual(1, type.ToNativeValue("adasdads"));
- Assert.Fail("Invalid format allowed");
- } catch ( FormatException )
- {
- }
- }
-
- [Test]
- public void UINT32_ReadWrite()
- {
- AMQType type = AMQType.UINT32;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const uint VALUE = 0xFFEEDDCC;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // UINT32 Tests
-
- #region VOID Tests
- [Test]
- public void VOID_CanGetEncodingSize()
- {
- AMQType type = AMQType.VOID;
- Assert.AreEqual(0, type.GetEncodingSize(null));
- }
-
- [Test]
- public void VOID_ToNativeValue()
- {
- AMQType type = AMQType.VOID;
- Assert.IsNull(type.ToNativeValue(null));
-
- try
- {
- type.ToNativeValue("asdasd");
- Assert.Fail("converted invalid value");
- } catch (FormatException)
- {
- }
- }
-
- [Test]
- public void VOID_ReadWrite()
- {
- AMQType type = AMQType.VOID;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
-
- type.WriteToBuffer(null, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(null, value.Value);
- }
-
- #endregion // VOID Tests
-
- #region BOOLEAN Tests
- [Test]
- public void BOOLEAN_CanGetEncodingSize()
- {
- AMQType type = AMQType.BOOLEAN;
- Assert.AreEqual(1, type.GetEncodingSize(true));
- }
-
- [Test]
- public void BOOLEAN_ToNativeValue()
- {
- AMQType type = AMQType.BOOLEAN;
- Assert.AreEqual(true, type.ToNativeValue(true));
- Assert.AreEqual(false, type.ToNativeValue("false"));
-
- try
- {
- type.ToNativeValue("asdasd");
- Assert.Fail("converted invalid value");
- } catch ( FormatException )
- {
- }
- }
-
- [Test]
- public void BOOLEAN_ReadWrite()
- {
- AMQType type = AMQType.BOOLEAN;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
-
- type.WriteToBuffer(true, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(true, value.Value);
- }
- #endregion // BOOLEAN Tests
-
- #region INT16 tests
- [Test]
- public void INT16_ReadWrite()
- {
- AMQType type = AMQType.INT16;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const short VALUE = -32765;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- //public void UINT16_ReadWrite()
- //{
- // AMQType type = AMQType.UINT16;
- // ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- // const ushort VALUE = 64321;
-
- // type.WriteToBuffer(VALUE, buffer);
- // buffer.Flip();
- // buffer.Rewind();
- // AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- // Assert.AreEqual(VALUE, value.Value);
- //}
- #endregion // INT16 Tests
-
- #region INT32 tests
- [Test]
- public void INT32_ReadWrite()
- {
- AMQType type = AMQType.INT32;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const int VALUE = -39273563;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // INT32 Tests
-
- #region INT64 tests
- [Test]
- public void INT64_ReadWrite()
- {
- AMQType type = AMQType.INT64;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const long VALUE = -(2^43+1233123);
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- [Test]
- public void UINT64_ReadWrite()
- {
- AMQType type = AMQType.UINT64;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const ulong VALUE = (2 ^ 61 + 1233123);
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // INT64 Tests
-
- #region FLOAT tests
- [Test]
- public void FLOAT_ReadWrite()
- {
- AMQType type = AMQType.FLOAT;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const float VALUE = 1.2345000E-035f;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // FLOAT Tests
-
- #region DOUBLE tests
- [Test]
- public void DOUBLE_ReadWrite()
- {
- AMQType type = AMQType.DOUBLE;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const double VALUE = 1.2345000E-045;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // FLOAT Tests
- }
-}
+/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +using System; +using NUnit.Framework; +using Apache.Qpid.Buffer; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Framing.Tests +{ + [TestFixture] + public class TestAMQType + { + + #region LONG_STRING tests + [Test] + public void LONG_STRING_ReadWrite() + { + AMQType type = AMQType.LONG_STRING; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const string VALUE = "simple string 1"; + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + #endregion // LONG_STRING tests + + #region UINT32 tests + [Test] + public void UINT32_CanGetEncodingSize() + { + AMQType type = AMQType.UINT32; + Assert.AreEqual(4, type.GetEncodingSize(1234443)); + } + + [Test] + public void UINT32_ToNativeValue() + { + AMQType type = AMQType.UINT32; + Assert.AreEqual(1, type.ToNativeValue(1)); + Assert.AreEqual(1, type.ToNativeValue((short)1)); + Assert.AreEqual(1, type.ToNativeValue((byte)1)); + Assert.AreEqual(1, type.ToNativeValue("1")); + + try + { + Assert.AreEqual(1, type.ToNativeValue("adasdads")); + Assert.Fail("Invalid format allowed"); + } catch ( FormatException ) + { + } + } + + [Test] + public void UINT32_ReadWrite() + { + AMQType type = AMQType.UINT32; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const uint VALUE = 0xFFEEDDCC; + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + #endregion // UINT32 Tests + + #region VOID Tests + [Test] + public void VOID_CanGetEncodingSize() + { + AMQType type = AMQType.VOID; + Assert.AreEqual(0, type.GetEncodingSize(null)); + } + + [Test] + public void VOID_ToNativeValue() + { + AMQType type = AMQType.VOID; + Assert.IsNull(type.ToNativeValue(null)); + + try + { + type.ToNativeValue("asdasd"); + Assert.Fail("converted invalid value"); + } catch (FormatException) + { + } + } + + [Test] + public void VOID_ReadWrite() + { + AMQType type = AMQType.VOID; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + + type.WriteToBuffer(null, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(null, value.Value); + } + + #endregion // VOID Tests + + #region BOOLEAN Tests + [Test] + public void BOOLEAN_CanGetEncodingSize() + { + AMQType type = AMQType.BOOLEAN; + Assert.AreEqual(1, type.GetEncodingSize(true)); + } + + [Test] + public void BOOLEAN_ToNativeValue() + { + AMQType type = AMQType.BOOLEAN; + Assert.AreEqual(true, type.ToNativeValue(true)); + Assert.AreEqual(false, type.ToNativeValue("false")); + + try + { + type.ToNativeValue("asdasd"); + Assert.Fail("converted invalid value"); + } catch ( FormatException ) + { + } + } + + [Test] + public void BOOLEAN_ReadWrite() + { + AMQType type = AMQType.BOOLEAN; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + + type.WriteToBuffer(true, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(true, value.Value); + } + #endregion // BOOLEAN Tests + + #region INT16 tests + [Test] + public void INT16_ReadWrite() + { + AMQType type = AMQType.INT16; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const short VALUE = -32765; + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + //public void UINT16_ReadWrite() + //{ + // AMQType type = AMQType.UINT16; + // ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + // const ushort VALUE = 64321; + + // type.WriteToBuffer(VALUE, buffer); + // buffer.Flip(); + // buffer.Rewind(); + // AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + // Assert.AreEqual(VALUE, value.Value); + //} + #endregion // INT16 Tests + + #region INT32 tests + [Test] + public void INT32_ReadWrite() + { + AMQType type = AMQType.INT32; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const int VALUE = -39273563; + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + #endregion // INT32 Tests + + #region INT64 tests + [Test] + public void INT64_ReadWrite() + { + AMQType type = AMQType.INT64; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const long VALUE = -(2^43+1233123); + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + [Test] + public void UINT64_ReadWrite() + { + AMQType type = AMQType.UINT64; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const ulong VALUE = (2 ^ 61 + 1233123); + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + #endregion // INT64 Tests + + #region FLOAT tests + [Test] + public void FLOAT_ReadWrite() + { + AMQType type = AMQType.FLOAT; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const float VALUE = 1.2345000E-035f; + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + #endregion // FLOAT Tests + + #region DOUBLE tests + [Test] + public void DOUBLE_ReadWrite() + { + AMQType type = AMQType.DOUBLE; + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + const double VALUE = 1.2345000E-045; + + type.WriteToBuffer(VALUE, buffer); + buffer.Flip(); + buffer.Rewind(); + AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); + Assert.AreEqual(VALUE, value.Value); + } + #endregion // FLOAT Tests + } +} diff --git a/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs b/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs index 720d7697d3..a8202dc70d 100644 --- a/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs +++ b/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs @@ -1,60 +1,60 @@ -/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-using System;
-using NUnit.Framework;
-using Apache.Qpid.Buffer;
-using Apache.Qpid.Framing;
-
-namespace Apache.Qpid.Framing.Tests
-{
- [TestFixture]
- public class TestEncodingUtils
- {
- [Test]
- public void CanReadLongAsShortString()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- EncodingUtils.WriteShortStringBytes(buffer, "98878122");
- buffer.Flip();
- long value = EncodingUtils.ReadLongAsShortString(buffer);
- Assert.AreEqual(98878122, value);
- }
- [Test]
- public void CanReadLongAsShortStringNegative()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- EncodingUtils.WriteShortStringBytes(buffer, "-98878122");
- buffer.Flip();
- long value = EncodingUtils.ReadLongAsShortString(buffer);
- Assert.AreEqual(-98878122, value);
- }
- [Test]
- public void CanReadLongAsShortStringEmpty()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- EncodingUtils.WriteShortStringBytes(buffer, "");
- buffer.Flip();
- long value = EncodingUtils.ReadLongAsShortString(buffer);
- Assert.AreEqual(0, value);
- }
-
- }
-}
+/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +using System; +using NUnit.Framework; +using Apache.Qpid.Buffer; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Framing.Tests +{ + [TestFixture] + public class TestEncodingUtils + { + [Test] + public void CanReadLongAsShortString() + { + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + EncodingUtils.WriteShortStringBytes(buffer, "98878122"); + buffer.Flip(); + long value = EncodingUtils.ReadLongAsShortString(buffer); + Assert.AreEqual(98878122, value); + } + [Test] + public void CanReadLongAsShortStringNegative() + { + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + EncodingUtils.WriteShortStringBytes(buffer, "-98878122"); + buffer.Flip(); + long value = EncodingUtils.ReadLongAsShortString(buffer); + Assert.AreEqual(-98878122, value); + } + [Test] + public void CanReadLongAsShortStringEmpty() + { + ByteBuffer buffer = ByteBuffer.Allocate(0x1000); + EncodingUtils.WriteShortStringBytes(buffer, ""); + buffer.Flip(); + long value = EncodingUtils.ReadLongAsShortString(buffer); + Assert.AreEqual(0, value); + } + + } +} |
