Exemplo n.º 1
0
		/// <exception cref="System.IO.IOException"></exception>
		private void DoTest()
		{
			dst = dstBuf.ToByteArray();
			DeltaIndex di = new DeltaIndex(src);
			di.Encode(actDeltaBuf, dst);
			byte[] actDelta = actDeltaBuf.ToByteArray();
			byte[] expDelta = expDeltaBuf.ToByteArray();
			NUnit.Framework.Assert.AreEqual(BinaryDelta.Format(expDelta, false), BinaryDelta.
				Format(actDelta, false));
			//
			NUnit.Framework.Assert.IsTrue(actDelta.Length > 0, "delta is not empty");
			NUnit.Framework.Assert.AreEqual(src.Length, BinaryDelta.GetBaseSize(actDelta));
			NUnit.Framework.Assert.AreEqual(dst.Length, BinaryDelta.GetResultSize(actDelta));
			CollectionAssert.AreEquivalent(dst, BinaryDelta.Apply(src, actDelta));
		}
Exemplo n.º 2
0
		public virtual void TestLimitObjectSize_Length130CopyOk()
		{
			src = GetRng().NextBytes(130);
			Copy(0, 130);
			dst = dstBuf.ToByteArray();
			DeltaIndex di = new DeltaIndex(src);
			NUnit.Framework.Assert.IsTrue(di.Encode(actDeltaBuf, dst, dst.Length));
			byte[] actDelta = actDeltaBuf.ToByteArray();
			byte[] expDelta = expDeltaBuf.ToByteArray();
			NUnit.Framework.Assert.AreEqual(BinaryDelta.Format(expDelta, false), BinaryDelta.
				Format(actDelta, false));
		}
Exemplo n.º 3
0
		public virtual void TestLimitObjectSize_InsertFrontFails()
		{
			src = GetRng().NextBytes(130);
			Insert("eight");
			Copy(0, 130);
			dst = dstBuf.ToByteArray();
			// The header requires 4 bytes for these objects, so a target length
			// of 5 is bigger than the copy instruction and should cause an abort.
			//
			DeltaIndex di = new DeltaIndex(src);
			NUnit.Framework.Assert.IsFalse(di.Encode(actDeltaBuf, dst, 5));
			NUnit.Framework.Assert.AreEqual(4, actDeltaBuf.Size());
		}
Exemplo n.º 4
0
		public virtual void TestLimitObjectSize_Length130InsertFails()
		{
			src = GetRng().NextBytes(130);
			dst = GetRng().NextBytes(130);
			DeltaIndex di = new DeltaIndex(src);
			NUnit.Framework.Assert.IsFalse(di.Encode(actDeltaBuf, dst, src.Length));
		}