8000 Push down Stream related helpers into BaseFixture · philhack/libgit2sharp@36945a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36945a9

Browse files
Aimeastnulltoken
authored andcommitted
Push down Stream related helpers into BaseFixture
1 parent 2bb26a5 commit 36945a9

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

LibGit2Sharp.Tests/BlobFixture.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -175,32 +175,6 @@ public void CanReadBlobFilteredStreamOfUnmodifiedBinary()
175175
}
176176
}
177177

178-
public static void CopyStream(Stream input, Stream output)
179-
{
180-
// Reused from the following Stack Overflow post with permission
181-
// of Jon Skeet (obtained on 25 Feb 2013)
182-
// http://stackoverflow.com/questions/411592/how-do-i-save-a-stream-to-a-file/411605#411605
183-
var buffer = new byte[8*1024];
184-
int len;
185-
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
186-
{
187-
output.Write(buffer, 0, len);
188-
}
189-
}
190-
191-
public static bool StreamEquals(Stream one, Stream two)
192-
{
193-
int onebyte, twobyte;
194-
195-
while ((onebyte = one.ReadByte()) >= 0 && (twobyte = two.ReadByte()) >= 0)
196-
{
197-
if (onebyte != twobyte)
198-
return false;
199-
}
200-
201-
return true;
202-
}
203-
204178
[Fact]
205179
public void CanStageAFileGeneratedFromABlobContentStream()
206180
{

LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,31 @@ protected static void EnableRefLog(Repository repository, bool enable = true)
324324
{
325325
repository.Config.Set("core.logAllRefUpdates", enable);
326326
}
327+
328+
public static void CopyStream(Stream input, Stream output)
329+
{
330+
// Reused from the following Stack Overflow post with permission
331+
// of Jon Skeet (obtained on 25 Feb 2013)
332+
// http://stackoverflow.com/questions/411592/how-do-i-save-a-stream-to-a-file/411605#411605
333+
var buffer = new byte[8 * 1024];
334+
int len;
335+
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
336+
{
337+
output.Write(buffer, 0, len);
338+
}
339+
}
340+
341+
public static bool StreamEquals(Stream one, Stream two)
342+
{
343+
int onebyte, twobyte;
344+
345+
while ((onebyte = one.ReadByte()) >= 0 && (twobyte = two.ReadByte()) >= 0)
346+
{
347+
if (onebyte != twobyte)
348+
return false;
349+
}
350+
351+
return true;
352+
}
327353
}
328354
}

0 commit comments

Comments
 (0)
0