1
+ using GitVersion ;
2
+ using GitVersion . Helpers ;
3
+ using NUnit . Framework ;
4
+ using Shouldly ;
1
5
using System ;
2
6
using System . ComponentModel ;
3
7
using System . IO ;
4
8
using System . Linq ;
5
9
using System . Reflection ;
6
10
using System . Runtime . CompilerServices ;
7
- using GitVersion ;
8
- using GitVersion . Helpers ;
9
- using NUnit . Framework ;
10
- using Shouldly ;
11
11
using YamlDotNet . Serialization ;
12
12
13
13
[ TestFixture ]
@@ -118,7 +118,7 @@ public void CanProvideConfigForNewBranch()
118
118
tag: bugfix" ;
119
119
SetupConfigFileContent ( text ) ;
120
120
var config = ConfigurationProvider . Provide ( repoPath , fileSystem ) ;
121
-
121
+
122
122
config . Branches [ "bug[/-]" ] . Tag . ShouldBe ( "bugfix" ) ;
123
123
}
124
124
@@ -151,7 +151,7 @@ public void NextVersionCanHavePatch()
151
151
152
152
config . NextVersion . ShouldBe ( "2.12.654651698" ) ;
153
153
}
154
-
154
+
155
155
[ Test ]
156
156
[ NUnit . Framework . Category ( "NoMono" ) ]
157
157
[ NUnit . Framework . Description ( "Won't run on Mono due to source information not being available for ShouldMatchApproved." ) ]
@@ -273,12 +273,13 @@ public void WarnOnAmbigousConfigFilesAtTheSameProjectRootDirectory(string path)
273
273
[ TestCase ( ConfigurationProvider . ObsoleteConfigFileName , ConfigurationProvider . ObsoleteConfigFileName ) ]
274
274
public void ThrowsExceptionOnAmbigousConfigFileLocation ( string repoConfigFile , string workingConfigFile )
275
275
{
276
- SetupConfigFileContent ( string . Empty , repoConfigFile , repoPath ) ;
277
- SetupConfigFileContent ( string . Empty , workingConfigFile , workingPath ) ;
276
+ var repositoryConfigFilePath = SetupConfigFileContent ( string . Empty , repoConfigFile , repoPath ) ;
277
+ var workingDirectoryConfigFilePath = SetupConfigFileContent ( string . Empty , workingConfigFile , workingPath ) ;
278
+
279
+ WarningException exception = Should . Throw < WarningException > ( ( ) => { ConfigurationProvider . Verify ( workingPath , repoPath , fileSystem ) ; } ) ;
278
280
279
- Should . Throw < WarningException > ( ( ) => {
280
- ConfigurationProvider . Verify ( workingPath , repoPath , fileSystem ) ;
281
- } ) ;
281
+ var expecedMessage = string . Format ( "Ambigous config file selection from '{0}' and '{1}'" , workingDirectoryConfigFilePath , repositoryConfigFilePath ) ;
282
+ exception . Message . ShouldBe ( expecedMessage ) ;
282
283
}
283
284
284
285
[ Test ]
@@ -295,13 +296,16 @@ public void NoWarnOnGitVersionYmlFile()
295
296
s . Length . ShouldBe ( 0 ) ;
296
297
}
297
298
298
- void SetupConfigFileContent ( string text , string fileName = ConfigurationProvider . DefaultConfigFileName )
299
+ string SetupConfigFileContent ( string text , string fileName = ConfigurationProvider . DefaultConfigFileName )
299
300
{
300
- SetupConfigFileContent ( text , fileName , repoPath ) ;
301
+ return SetupConfigFileContent ( text , fileName , repoPath ) ;
301
302
}
302
303
303
- void SetupConfigFileContent ( string text , string fileName , string path )
304
+ string SetupConfigFileContent ( string text , string fileName , string path )
304
305
{
305
- fileSystem . WriteAllText ( Path . Combine ( path , fileName ) , text ) ;
306
+ var fullPath = Path . Combine ( path , fileName ) ;
307
+ fileSystem . WriteAllText ( fullPath , text ) ;
308
+
309
+ return fullPath ;
306
310
}
307
- }
311
+ }
0 commit comments