本文整理汇总了C#中TestRepository.ParseBody方法的典型用法代码示例。如果您正苦于以下问题:C# TestRepository.ParseBody方法的具体用法?C# TestRepository.ParseBody怎么用?C# TestRepository.ParseBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRepository
的用法示例。
在下文中一共展示了TestRepository.ParseBody方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestUsingHiddenDeltaBaseFails
public virtual void TestUsingHiddenDeltaBaseFails()
{
byte[] delta = new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
(int)(0x1)), (byte)('c') };
TestRepository<Repository> s = new TestRepository<Repository>(src);
RevCommit N = s.Commit().Parent(B).Add("q", s.Blob(BinaryDelta.Apply(dst.Open(b).
GetCachedBytes(), delta))).Create();
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 3);
Copy(pack, src.Open(N));
Copy(pack, src.Open(s.ParseBody(N).Tree));
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
b.CopyRawTo(pack);
Deflate(pack, delta);
Digest(pack);
TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
PacketLineOut inPckLine = new PacketLineOut(inBuf);
inPckLine.WriteString(ObjectId.ZeroId.Name + ' ' + N.Name + ' ' + "refs/heads/s"
+ '\0' + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
inPckLine.End();
pack.WriteTo(inBuf, PM);
TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
ReceivePack rp = new ReceivePack(dst);
rp.SetCheckReceivedObjects(true);
rp.SetCheckReferencedObjectsAreReachable(true);
rp.SetAdvertiseRefsHook(new ReceivePackAdvertiseRefsHookTest.HidePrivateHook());
try
{
Receive(rp, inBuf, outBuf);
NUnit.Framework.Assert.Fail("Expected UnpackException");
}
catch (UnpackException failed)
{
Exception err = failed.InnerException;
NUnit.Framework.Assert.IsTrue(err is MissingObjectException);
MissingObjectException moe = (MissingObjectException)err;
NUnit.Framework.Assert.AreEqual(b, moe.GetObjectId());
}
PacketLineIn r = AsPacketLineIn(outBuf);
string master = r.ReadString();
int nul = master.IndexOf('\0');
NUnit.Framework.Assert.IsTrue(nul > 0, "has capability list");
NUnit.Framework.Assert.AreEqual(B.Name + ' ' + R_MASTER, Sharpen.Runtime.Substring
(master, 0, nul));
NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
NUnit.Framework.Assert.AreEqual("unpack error Missing blob " + b.Name, r.ReadString
());
NUnit.Framework.Assert.AreEqual("ng refs/heads/s n/a (unpacker error)", r.ReadString
());
NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
}
示例2: TestUsingUnknownTreeFails
public virtual void TestUsingUnknownTreeFails()
{
TestRepository<Repository> s = new TestRepository<Repository>(src);
RevCommit N = s.Commit().Parent(B).Add("q", s.Blob("a")).Create();
RevTree t = s.ParseBody(N).Tree;
// Don't include the tree in the pack.
//
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
Copy(pack, src.Open(N));
Digest(pack);
TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
PacketLineOut inPckLine = new PacketLineOut(inBuf);
inPckLine.WriteString(ObjectId.ZeroId.Name + ' ' + N.Name + ' ' + "refs/heads/s"
+ '\0' + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
inPckLine.End();
pack.WriteTo(inBuf, PM);
TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
ReceivePack rp = new ReceivePack(dst);
rp.SetCheckReceivedObjects(true);
rp.SetCheckReferencedObjectsAreReachable(true);
rp.SetAdvertiseRefsHook(new ReceivePackAdvertiseRefsHookTest.HidePrivateHook());
try
{
Receive(rp, inBuf, outBuf);
NUnit.Framework.Assert.Fail("Expected UnpackException");
}
catch (UnpackException failed)
{
Exception err = failed.InnerException;
NUnit.Framework.Assert.IsTrue(err is MissingObjectException);
MissingObjectException moe = (MissingObjectException)err;
NUnit.Framework.Assert.AreEqual(t, moe.GetObjectId());
}
PacketLineIn r = AsPacketLineIn(outBuf);
string master = r.ReadString();
int nul = master.IndexOf('\0');
NUnit.Framework.Assert.IsTrue(nul > 0, "has capability list");
NUnit.Framework.Assert.AreEqual(B.Name + ' ' + R_MASTER, Sharpen.Runtime.Substring
(master, 0, nul));
NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
NUnit.Framework.Assert.AreEqual("unpack error Missing tree " + t.Name, r.ReadString
());
NUnit.Framework.Assert.AreEqual("ng refs/heads/s n/a (unpacker error)", r.ReadString
());
NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
}
示例3: SetUp
public override void SetUp()
{
base.SetUp();
tr = new TestRepository<Repository>(db);
reader = db.NewObjectReader();
inserter = db.NewObjectInserter();
noRoot = NoteMap.NewMap(null, reader);
empty = NoteMap.NewEmptyMap();
noteAId = tr.Blob("a");
noteAContent = "noteAContent";
noteABlob = tr.Blob(noteAContent);
sampleTree_a = tr.Commit().Add(noteAId.Name, noteABlob).Create();
tr.ParseBody(sampleTree_a);
map_a = NoteMap.Read(reader, sampleTree_a);
noteBId = tr.Blob("b");
noteBContent = "noteBContent";
noteBBlob = tr.Blob(noteBContent);
sampleTree_a_b = tr.Commit().Add(noteAId.Name, noteABlob).Add(noteBId.Name, noteBBlob
).Create();
tr.ParseBody(sampleTree_a_b);
map_a_b = NoteMap.Read(reader, sampleTree_a_b);
}