public void CollectTonsOfDataInOneChunk()
		{
			var dataCollector = new DataCollector();
			dataCollector.ObjectFinished += container => collectedDataObjects.Add(container);
			Assert.IsEmpty(collectedDataObjects);
			var hugeByteArray = GetTestBytesWithLengthHeader(9348);
			dataCollector.ReadBytes(hugeByteArray, 0, hugeByteArray.Length);
			Assert.AreEqual(1, collectedDataObjects.Count);
		}
Beispiel #2
0
 public TcpSocket(Socket nativeSocket)
 {
     this.nativeSocket = nativeSocket;
     buffer = new byte[ReceiveBufferSize];
     dataCollector = new DataCollector();
     dataCollector.ObjectFinished += OnObjectFinished;
     isDisposed = false;
     Timeout = DefaultTimeout;
 }
		public void CollectData()
		{
			var dataCollector = new DataCollector();
			dataCollector.ObjectFinished += container => collectedDataObjects.Add(container);
			Assert.IsEmpty(collectedDataObjects);
			var bytePackages = SplitDataStream(CreateByteList(), 7, 7, 8, 3, 1);
			foreach (byte[] package in bytePackages)
				dataCollector.ReadBytes(package, 0, package.Length);
			Assert.AreEqual(3, collectedDataObjects.Count);
		}
		public void CollectDataWithIncompleteMessage()
		{
			var dataCollector = new DataCollector();
			dataCollector.ObjectFinished += container => collectedDataObjects.Add(container);
			var byteArray = GetTestBytesWithLengthHeader(1);
			dataCollector.ReadBytes(byteArray, 0, 0);
			dataCollector.ReadBytes(byteArray, 0, byteArray.Length - 1);
			dataCollector.ReadBytes(byteArray, byteArray.Length - 1, 1);
			Assert.AreEqual(1, collectedDataObjects.Count);
			Assert.AreEqual(1, collectedDataObjects[0].Data.Length);
			Assert.AreEqual(100, collectedDataObjects[0].Data[0]);
		}