Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 30a4d0b

Browse files
authored
Merge pull request #552 from github/grokys/temp-repository
Added TempRepository helper class.
2 parents 38a687e + 86ce4b8 commit 30a4d0b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/UnitTests/Helpers/TestBaseClass.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Octokit;
44
using System;
55
using System.IO;
6+
using System.IO.Compression;
67
using Xunit.Abstractions;
78

89
/// <summary>
@@ -82,4 +83,23 @@ public void Dispose()
8283
Directory.Delete(true);
8384
}
8485
}
86+
87+
protected class TempRepository : TempDirectory
88+
{
89+
public TempRepository(string name, byte[] repositoryZip)
90+
: base()
91+
{
92+
var outputZip = Path.Combine(Directory.FullName, name + ".zip");
93+
var outputDir = Path.Combine(Directory.FullName, name);
94+
var repositoryPath = Path.Combine(outputDir, name);
95+
File.WriteAllBytes(outputZip, repositoryZip);
96+
ZipFile.ExtractToDirectory(outputZip, outputDir);
97+
Repository = new LibGit2Sharp.Repository(repositoryPath);
98+
}
99+
100+
public LibGit2Sharp.Repository Repository
101+
{
102+
get;
103+
}
104+
}
85105
}

src/UnitTests/UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<Reference Include="System" />
109109
<Reference Include="System.ComponentModel.Composition" />
110110
<Reference Include="System.Core" />
111+
<Reference Include="System.IO.Compression.FileSystem" />
111112
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=62aa029873c516b4, processorArchitecture=MSIL">
112113
<HintPath>..\..\packages\Rx-Core.2.2.5-custom\lib\net45\System.Reactive.Core.dll</HintPath>
113114
<Private>True</Private>

0 commit comments

Comments
 (0)