Fix issue in buffer compact and enable fixed tests
diff --git a/src/Proton/Buffer/ProtonCompositeBuffer.cs b/src/Proton/Buffer/ProtonCompositeBuffer.cs
index f640153..cc8c736 100644
--- a/src/Proton/Buffer/ProtonCompositeBuffer.cs
+++ b/src/Proton/Buffer/ProtonCompositeBuffer.cs
@@ -256,15 +256,18 @@
int position = 0;
long oldReadOffset = readOffset;
- ForEachReadableComponent(unused, (index, component) =>
+ if (IsReadable)
{
- for (int i = 0; i < component.ReadableArrayLength; ++i)
+ ForEachReadableComponent(unused, (index, component) =>
{
- SetUnsignedByte(position++, component.ReadableArray[component.ReadableArrayOffset + i]);
- }
+ for (int i = 0; i < component.ReadableArrayLength; ++i)
+ {
+ SetUnsignedByte(position++, component.ReadableArray[component.ReadableArrayOffset + i]);
+ }
- return true;
- });
+ return true;
+ });
+ }
ReadOffset = 0;
WriteOffset = writeOffset - oldReadOffset;
diff --git a/test/Proton.Client.Tests/Client/Implementation/ClientStreamReceiverTest.cs b/test/Proton.Client.Tests/Client/Implementation/ClientStreamReceiverTest.cs
index 21dea79..202b3f2 100644
--- a/test/Proton.Client.Tests/Client/Implementation/ClientStreamReceiverTest.cs
+++ b/test/Proton.Client.Tests/Client/Implementation/ClientStreamReceiverTest.cs
@@ -671,7 +671,6 @@
}
}
- [Ignore("Raw input stream access not yet implemented.")]
[Test]
public void TestStreamDeliveryRawInputStreamWithCompleteDeliveryReadByte()
{
@@ -791,7 +790,6 @@
}
}
- [Ignore("Raw input stream is not fully implemented")]
[Test]
public void TestStreamDeliveryRawInputStreamWithCompleteDeliveryReadBytes()
{
@@ -1373,7 +1371,6 @@
}
}
- [Ignore("Raw input stream is not fully implemented")]
[Test]
public void TestStreamDeliveryUserAppliedDispositionBeforeStreamRead()
{
@@ -1501,7 +1498,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestReadHeaderFromStreamMessageWithoutHeaderSection()
{
@@ -1560,7 +1556,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestTryReadSectionBeyondWhatIsEncodedIntoMessage()
{
@@ -2674,7 +2669,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestStreamDeliveryHandlesInvalidHeaderEncoding()
{
@@ -2726,7 +2720,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestStreamDeliveryHandlesInvalidDeliveryAnnotationsEncoding()
{
@@ -2778,7 +2771,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestStreamDeliveryHandlesInvalidMessageAnnotationsEncoding()
{
@@ -2830,7 +2822,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestStreamDeliveryHandlesInvalidPropertiesEncoding()
{
@@ -2882,7 +2873,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestStreamDeliveryHandlesInvalidApplicationPropertiesEncoding()
{
@@ -2934,7 +2924,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestStreamDeliveryHandlesInvalidHeaderEncodingDuringBodyStreamOpen()
{
@@ -2986,7 +2975,6 @@
}
}
- [Ignore("Stream Receiver is not fully implemented")]
[Test]
public void TestConnectionDropsDuringStreamedBodyRead()
{
@@ -4029,6 +4017,5 @@
peer.WaitForScriptToComplete();
}
}
-
}
}
\ No newline at end of file
diff --git a/test/Proton.Tests/Buffer/ProtonAbstractByteBufferTests.cs b/test/Proton.Tests/Buffer/ProtonAbstractByteBufferTests.cs
index 02670e0..4944464 100644
--- a/test/Proton.Tests/Buffer/ProtonAbstractByteBufferTests.cs
+++ b/test/Proton.Tests/Buffer/ProtonAbstractByteBufferTests.cs
@@ -2528,6 +2528,24 @@
#region Test for buffer compaction
[Test]
+ public void TestCompactBufferWithOneByteWrittenAndRead()
+ {
+ IProtonBuffer buffer = AllocateBuffer(16);
+
+ buffer.WriteByte(127);
+ Assert.AreEqual(127, buffer.ReadByte());
+
+ Assert.AreEqual(1, buffer.ReadOffset);
+ Assert.AreEqual(1, buffer.WriteOffset);
+ Assert.AreEqual(16, buffer.Capacity);
+
+ Assert.AreSame(buffer, buffer.Compact());
+
+ Assert.AreEqual(0, buffer.ReadOffset);
+ Assert.AreEqual(0, buffer.WriteOffset);
+ }
+
+ [Test]
public void TestCompactMustDiscardReadBytes()
{
IProtonBuffer buffer = AllocateBuffer(16);