1
1
using System ;
2
+ using System . IO ;
2
3
using System . Linq ;
3
4
using System . Threading ;
4
- using GitHub . Unity ;
5
5
using System . Threading . Tasks ;
6
- using NSubstitute ;
6
+ using GitHub . Unity ;
7
7
8
8
namespace IntegrationTests
9
9
{
10
- class BaseGitEnvironmentTest : BaseGitRepoTest
10
+ class BaseGitEnvironmentTest : BasePlatformIntegrationTest
11
11
{
12
12
protected async Task < IEnvironment > Initialize ( NPath repoPath , NPath environmentPath = null ,
13
- bool enableEnvironmentTrace = false , bool initializeRepository = true , Action < RepositoryManager > onRepositoryManagerCreated = null )
13
+ bool enableEnvironmentTrace = false , bool initializeRepository = true ,
14
+ Action < RepositoryManager > onRepositoryManagerCreated = null )
14
15
{
15
- TaskManager = new TaskManager ( ) ;
16
- SyncContext = new ThreadSynchronizationContext ( TaskManager . Token ) ;
17
- TaskManager . UIScheduler = new SynchronizationContextTaskScheduler ( SyncContext ) ;
18
-
19
- //TODO: Mock CacheContainer
20
- ICacheContainer cacheContainer = Substitute . For < ICacheContainer > ( ) ;
21
- Environment = new IntegrationTestEnvironment ( cacheContainer , repoPath , SolutionDirectory , environmentPath , enableEnvironmentTrace ) ;
22
-
23
- var gitSetup = new GitInstaller ( Environment , TaskManager . Token ) ;
24
- await gitSetup . SetupIfNeeded ( ) ;
25
- Environment . GitExecutablePath = gitSetup . GitExecutablePath ;
26
-
27
- Platform = new Platform ( Environment ) ;
16
+ await InitializePlatform ( repoPath , environmentPath , enableEnvironmentTrace ) ;
28
17
29
- GitEnvironment = Platform . GitEnvironment ;
30
- ProcessManager = new ProcessManager ( Environment , GitEnvironment , TaskManager . Token ) ;
31
-
32
- Platform . Initialize ( ProcessManager , TaskManager ) ;
33
-
34
- GitClient = new GitClient ( Environment , ProcessManager , TaskManager ) ;
35
-
36
- var repositoryManager = GitHub . Unity . RepositoryManager . CreateInstance ( Platform , TaskManager , GitClient , repoPath ) ;
18
+ var repositoryManager =
19
+ GitHub . Unity . RepositoryManager . CreateInstance ( Platform , TaskManager , GitClient , repoPath ) ;
37
20
onRepositoryManagerCreated ? . Invoke ( repositoryManager ) ;
38
21
39
22
RepositoryManager = repositoryManager ;
40
23
RepositoryManager . Initialize ( ) ;
41
24
42
25
if ( initializeRepository )
43
26
{
44
- Environment . Repository = new Repository ( repoPath , cacheContainer ) ;
27
+ Environment . Repository = new Repository ( repoPath , CacheContainer ) ;
45
28
Environment . Repository . Initialize ( RepositoryManager ) ;
46
29
}
47
30
@@ -51,11 +34,8 @@ protected async Task<IEnvironment> Initialize(NPath repoPath, NPath environmentP
51
34
52
35
if ( DotGitPath . FileExists ( ) )
53
36
{
54
- DotGitPath =
55
- DotGitPath . ReadAllLines ( )
56
- . Where ( x => x . StartsWith ( "gitdir:" ) )
57
- . Select ( x => x . Substring ( 7 ) . Trim ( ) . ToNPath ( ) )
58
- . First ( ) ;
37
+ DotGitPath = DotGitPath . ReadAllLines ( ) . Where ( x => x . StartsWith ( "gitdir:" ) )
38
+ . Select ( x => x . Substring ( 7 ) . Trim ( ) . ToNPath ( ) ) . First ( ) ;
59
39
}
60
40
61
41
BranchesPath = DotGitPath . Combine ( "refs" , "heads" ) ;
@@ -66,6 +46,21 @@ protected async Task<IEnvironment> Initialize(NPath repoPath, NPath environmentP
66
46
return Environment ;
67
47
}
68
48
49
+ public override void OnSetup ( )
50
+ {
51
+ base . OnSetup ( ) ;
52
+
53
+ TestRepoMasterCleanUnsynchronized = TestBasePath . Combine ( "IOTestsRepo" , "IOTestsRepo_master_clean_unsync" ) ;
54
+ TestRepoMasterCleanUnsynchronizedRussianLanguage = TestBasePath . Combine ( "IOTestsRepo" , "IOTestsRepo_master_clean_sync_with_russian_language" ) ;
55
+ TestRepoMasterCleanSynchronized = TestBasePath . Combine ( "IOTestsRepo" , "IOTestsRepo_master_clean_sync" ) ;
56
+ TestRepoMasterDirtyUnsynchronized = TestBasePath . Combine ( "IOTestsRepo" , "IOTestsRepo_master_dirty_unsync" ) ;
57
+ TestRepoMasterTwoRemotes = TestBasePath . Combine ( "IOTestsRepo" , "IOTestsRepo_master_two_remotes" ) ;
58
+
59
+ Logger . Trace ( "Extracting Zip File to {0}" , TestBasePath ) ;
60
+ ZipHelper . ExtractZipFile ( TestZipFilePath , TestBasePath . ToString ( ) , CancellationToken . None ) ;
61
+ Logger . Trace ( "Extracted Zip File" ) ;
62
+ }
63
+
69
64
public override void OnTearDown ( )
70
65
{
71
66
RepositoryManager ? . Stop ( ) ;
@@ -76,14 +71,7 @@ public override void OnTearDown()
76
71
77
72
public IRepositoryManager RepositoryManager { get ; private set ; }
78
73
79
- protected IPlatform Platform { get ; private set ; }
80
74
protected IApplicationManager ApplicationManager { get ; set ; }
81
- protected IProcessManager ProcessManager { get ; private set ; }
82
- protected ITaskManager TaskManager { get ; private set ; }
83
-
84
- protected IProcessEnvironment GitEnvironment { get ; private set ; }
85
- protected IGitClient GitClient { get ; set ; }
86
- protected SynchronizationContext SyncContext { get ; set ; }
87
75
88
76
protected NPath DotGitConfig { get ; private set ; }
89
77
@@ -96,5 +84,17 @@ public override void OnTearDown()
96
84
protected NPath BranchesPath { get ; private set ; }
97
85
98
86
protected NPath DotGitPath { get ; private set ; }
87
+
88
+ protected NPath TestRepoMasterCleanSynchronized { get ; private set ; }
89
+
90
+ protected NPath TestRepoMasterCleanUnsynchronized { get ; private set ; }
91
+
92
+ protected NPath TestRepoMasterCleanUnsynchronizedRussianLanguage { get ; private set ; }
93
+
94
+ protected NPath TestRepoMasterDirtyUnsynchronized { get ; private set ; }
95
+
96
+ protected NPath TestRepoMasterTwoRemotes { get ; private set ; }
97
+
98
+ private static string TestZipFilePath => Path . Combine ( SolutionDirectory , "IOTestsRepo.zip" ) ;
99
99
}
100
100
}
0 commit comments