本文整理汇总了C#中TestRepository.Blob方法的典型用法代码示例。如果您正苦于以下问题:C# TestRepository.Blob方法的具体用法?C# TestRepository.Blob怎么用?C# TestRepository.Blob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRepository
的用法示例。
在下文中一共展示了TestRepository.Blob方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public override void SetUp()
{
base.SetUp();
tr = new TestRepository<Repository>(db);
reader = db.NewObjectReader();
inserter = db.NewObjectInserter();
merger = new DefaultNoteMerger();
noteOn = tr.Blob("a");
baseNote = NewNote("data");
}
示例2: SetUp
/// <exception cref="System.Exception"></exception>
public override void SetUp()
{
base.SetUp();
tr = new TestRepository<Repository>(db);
git = new Git(db);
// commit something
WriteTrashFile("Test.txt", "Hello world");
git.Add().AddFilepattern("Test.txt").Call();
git.Commit().SetMessage("Initial commit").Call();
// create a master branch and switch to it
git.BranchCreate().SetName("test").Call();
RefUpdate rup = db.UpdateRef(Constants.HEAD);
rup.Link("refs/heads/test");
// commit something on the test branch
WriteTrashFile("Test.txt", "Some change");
git.Add().AddFilepattern("Test.txt").Call();
git.Commit().SetMessage("Second commit").Call();
RevBlob blob = tr.Blob("blob-not-in-master-branch");
git.Tag().SetName("tag-for-blob").SetObjectId(blob).Call();
}
示例3: TestTinyThinPack
public virtual void TestTinyThinPack()
{
TestRepository d = new TestRepository(db);
RevBlob a = d.Blob("a");
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
a.CopyRawTo(pack);
Deflate(pack, new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
(int)(0x1)), (byte)('b') });
Digest(pack);
PackParser p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetAllowThin(true);
p.Parse(NullProgressMonitor.INSTANCE);
}
示例4: TestPackWithTrailingGarbage
public virtual void TestPackWithTrailingGarbage()
{
TestRepository d = new TestRepository(db);
RevBlob a = d.Blob("a");
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
a.CopyRawTo(pack);
Deflate(pack, new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
(int)(0x1)), (byte)('b') });
Digest(pack);
PackParser p = Index(new UnionInputStream(new ByteArrayInputStream(pack.ToByteArray
()), new ByteArrayInputStream(new byte[] { unchecked((int)(0x7e)) })));
p.SetAllowThin(true);
p.SetCheckEofAfterPackFooter(true);
try
{
p.Parse(NullProgressMonitor.INSTANCE);
NUnit.Framework.Assert.Fail("Pack with trailing garbage was accepted");
}
catch (IOException err)
{
NUnit.Framework.Assert.AreEqual(MessageFormat.Format(JGitText.Get().expectedEOFReceived
, "\\x7e"), err.Message);
}
}
示例5: TestPackWithDuplicateBlob
public virtual void TestPackWithDuplicateBlob()
{
byte[] data = Constants.Encode("0123456789abcdefg");
TestRepository<Repository> d = new TestRepository<Repository>(db);
NUnit.Framework.Assert.IsTrue(db.HasObject(d.Blob(data)));
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_BLOB) << 4 | unchecked((int)(0x80)) | 1);
pack.Write(1);
Deflate(pack, data);
Digest(pack);
PackParser p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetAllowThin(false);
p.Parse(NullProgressMonitor.INSTANCE);
}
示例6: TestMaxObjectSizeFullBlob
public virtual void TestMaxObjectSizeFullBlob()
{
TestRepository d = new TestRepository(db);
byte[] data = Constants.Encode("0123456789");
d.Blob(data);
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_BLOB) << 4 | 10);
Deflate(pack, data);
Digest(pack);
PackParser p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetMaxObjectSizeLimit(11);
p.Parse(NullProgressMonitor.INSTANCE);
p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetMaxObjectSizeLimit(10);
p.Parse(NullProgressMonitor.INSTANCE);
p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetMaxObjectSizeLimit(9);
try
{
p.Parse(NullProgressMonitor.INSTANCE);
NUnit.Framework.Assert.Fail("PackParser should have failed");
}
catch (TooLargeObjectInPackException e)
{
NUnit.Framework.Assert.IsTrue(e.Message.Contains("10"));
// obj size
NUnit.Framework.Assert.IsTrue(e.Message.Contains("9"));
}
}
示例7: TestMaxObjectSizeDeltaResultSize
public virtual void TestMaxObjectSizeDeltaResultSize()
{
TestRepository d = new TestRepository(db);
RevBlob a = d.Blob("0123456789");
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
a.CopyRawTo(pack);
Deflate(pack, new byte[] { 10, 11, 1, (byte)('a') });
Digest(pack);
PackParser p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetAllowThin(true);
p.SetMaxObjectSizeLimit(11);
p.Parse(NullProgressMonitor.INSTANCE);
p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetAllowThin(true);
p.SetMaxObjectSizeLimit(10);
try
{
p.Parse(NullProgressMonitor.INSTANCE);
NUnit.Framework.Assert.Fail("PackParser should have failed");
}
catch (TooLargeObjectInPackException e)
{
NUnit.Framework.Assert.IsTrue(e.Message.Contains("11"));
// result obj size
NUnit.Framework.Assert.IsTrue(e.Message.Contains("10"));
}
}
示例8: SetUp
public override void SetUp()
{
base.SetUp();
src = CreateBareRepository();
dst = CreateBareRepository();
// Fill dst with a some common history.
//
TestRepository d = new TestRepository<Repository>(dst);
a = d.Blob("a");
A = d.Commit(d.Tree(d.File("a", a)));
B = d.Commit().Parent(A).Create();
d.Update(R_MASTER, B);
// Clone from dst into src
//
NGit.Transport.Transport t = NGit.Transport.Transport.Open(src, UriOf(dst));
try
{
t.Fetch(PM, Collections.Singleton(new RefSpec("+refs/*:refs/*")));
NUnit.Framework.Assert.AreEqual(B, src.Resolve(R_MASTER));
}
finally
{
t.Close();
}
// Now put private stuff into dst.
//
b = d.Blob("b");
P = d.Commit(d.Tree(d.File("b", b)), A);
d.Update(R_PRIVATE, P);
}
示例9: 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());
}
示例10: 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());
}
示例11: TestDataAfterPackFooterSplitHeaderRead
public virtual void TestDataAfterPackFooterSplitHeaderRead()
{
TestRepository d = new TestRepository<FileRepository>(db);
byte[] data = Constants.Encode("a");
RevBlob b = d.Blob(data);
int objects = 248;
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(32 * 1024);
PackHeader(pack, objects + 1);
int offset = 13;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < offset; i++)
{
sb.Append(i);
}
offset = sb.ToString().Length;
int lenByte = (Constants.OBJ_BLOB) << 4 | (offset & unchecked((int)(0x0F)));
offset >>= 4;
if (offset > 0)
{
lenByte |= 1 << 7;
}
pack.Write(lenByte);
while (offset > 0)
{
lenByte = offset & unchecked((int)(0x7F));
offset >>= 6;
if (offset > 0)
{
lenByte |= 1 << 7;
}
pack.Write(lenByte);
}
Deflate(pack, Constants.Encode(sb.ToString()));
for (int i_1 = 0; i_1 < objects; i_1++)
{
// The last pack header written falls across the 8192 byte boundary
// between [8189:8210]
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
b.CopyRawTo(pack);
Deflate(pack, new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
(int)(0x1)), (byte)('b') });
}
Digest(pack);
byte[] packData = pack.ToByteArray();
byte[] streamData = new byte[packData.Length + 1];
System.Array.Copy(packData, 0, streamData, 0, packData.Length);
streamData[packData.Length] = unchecked((int)(0x7e));
InputStream @in = new ByteArrayInputStream(streamData);
PackParser p = Index(@in);
p.SetAllowThin(true);
p.SetCheckEofAfterPackFooter(false);
p.SetExpectDataAfterPackFooter(true);
p.Parse(NullProgressMonitor.INSTANCE);
NUnit.Framework.Assert.AreEqual(unchecked((int)(0x7e)), @in.Read());
}
示例12: TestDataAfterPackFooterSingleRead
public virtual void TestDataAfterPackFooterSingleRead()
{
TestRepository d = new TestRepository<FileRepository>(db);
RevBlob a = d.Blob("a");
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(32 * 1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
a.CopyRawTo(pack);
Deflate(pack, new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
(int)(0x1)), (byte)('b') });
Digest(pack);
byte[] packData = pack.ToByteArray();
byte[] streamData = new byte[packData.Length + 1];
System.Array.Copy(packData, 0, streamData, 0, packData.Length);
streamData[packData.Length] = unchecked((int)(0x7e));
InputStream @in = new ByteArrayInputStream(streamData);
PackParser p = Index(@in);
p.SetAllowThin(true);
p.SetCheckEofAfterPackFooter(false);
p.SetExpectDataAfterPackFooter(true);
p.Parse(NullProgressMonitor.INSTANCE);
NUnit.Framework.Assert.AreEqual(unchecked((int)(0x7e)), @in.Read());
}
示例13: TestNonMarkingInputStream
public virtual void TestNonMarkingInputStream()
{
TestRepository d = new TestRepository<FileRepository>(db);
RevBlob a = d.Blob("a");
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
a.CopyRawTo(pack);
Deflate(pack, new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
(int)(0x1)), (byte)('b') });
Digest(pack);
InputStream @in = new _ByteArrayInputStream_319(pack.ToByteArray());
PackParser p = Index(@in);
p.SetAllowThin(true);
p.SetCheckEofAfterPackFooter(false);
p.SetExpectDataAfterPackFooter(true);
try
{
p.Parse(NullProgressMonitor.INSTANCE);
NUnit.Framework.Assert.Fail("PackParser should have failed");
}
catch (IOException e)
{
NUnit.Framework.Assert.AreEqual(e.Message, JGitText.Get().inputStreamMustSupportMark
);
}
}
示例14: TestMaxObjectSizeDeltaBlock
public virtual void TestMaxObjectSizeDeltaBlock()
{
TestRepository d = new TestRepository<FileRepository>(db);
RevBlob a = d.Blob("a");
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
PackHeader(pack, 1);
pack.Write((Constants.OBJ_REF_DELTA) << 4 | 14);
a.CopyRawTo(pack);
Deflate(pack, new byte[] { 1, 11, 11, (byte)('a'), (byte)('0'), (byte)('1'), (byte
)('2'), (byte)('3'), (byte)('4'), (byte)('5'), (byte)('6'), (byte)('7'), (byte)(
'8'), (byte)('9') });
Digest(pack);
PackParser p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetAllowThin(true);
p.SetMaxObjectSizeLimit(14);
p.Parse(NullProgressMonitor.INSTANCE);
p = Index(new ByteArrayInputStream(pack.ToByteArray()));
p.SetAllowThin(true);
p.SetMaxObjectSizeLimit(13);
try
{
p.Parse(NullProgressMonitor.INSTANCE);
NUnit.Framework.Assert.Fail("PackParser should have failed");
}
catch (TooLargeObjectInPackException e)
{
NUnit.Framework.Assert.IsTrue(e.Message.Contains("13"));
// max obj size
NUnit.Framework.Assert.IsFalse(e.Message.Contains("14"));
}
}
示例15: 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);
}