diff options
author | Paul Duncan <jpaulduncan@gmail.com> | 2014-09-09 00:13:57 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2014-09-13 22:21:00 +0400 |
commit | 91c04d89914592acb9f74e54891b217ca3508ae6 (patch) | |
tree | abce46497fde9430d1a4afe0f253f99473479701 /LibGit2Sharp.Tests | |
parent | b8225a73f303849a0858a38a9816b34f069b9740 (diff) |
Deprecate repo.Version in favor of GlobalSettings.Version
Fix #726
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/GlobalSettingsFixture.cs | 39 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/RepositoryFixture.cs | 35 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs | 6 |
3 files changed, 39 insertions, 41 deletions
diff --git a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs index 29935903..d8533f03 100644 --- a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs +++ b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs @@ -1,5 +1,4 @@ -using System; -using LibGit2Sharp; +using System.Text.RegularExpressions; using LibGit2Sharp.Tests.TestHelpers; using Xunit; @@ -10,10 +9,44 @@ namespace LibGit2Sharp.Tests [Fact] public void CanGetMinimumCompiledInFeatures() { - BuiltInFeatures features = GlobalSettings.Features(); + BuiltInFeatures features = GlobalSettings.Version.Features; Assert.True(features.HasFlag(BuiltInFeatures.Threads)); Assert.True(features.HasFlag(BuiltInFeatures.Https)); } + + [Fact] + public void CanRetrieveValidVersionString() + { + // Version string format is: + // Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features) + // Example output: + // "0.17.0-unknown-06d772d (x86 - Threads, Https)" + + string versionInfo = GlobalSettings.Version.ToString(); + + // The GlobalSettings.Version returned string should contain : + // version:'0.17.0' LibGit2Sharp version number. + // git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash. + // git2hash: '06d772d' LibGit2 library hash. + // arch: 'x86' or 'amd64' LibGit2 target. + // git2Features: 'Threads, Ssh' LibGit2 features compiled with. + string regex = @"^(?<version>\d{1,}\.\d{1,2}\.\d{1,3})-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$"; + + Assert.NotNull(versionInfo); + + Match regexResult = Regex.Match(versionInfo, regex); + + Assert.True(regexResult.Success, "The following version string format is enforced:" + + "Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)"); + + GroupCollection matchGroups = regexResult.Groups; + + // Check that all groups are valid + foreach (Group group in matchGroups) + { + Assert.True(group.Success); + } + } } } diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs index 7f4d208a..62ca9e1b 100644 --- a/LibGit2Sharp.Tests/RepositoryFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryFixture.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using LibGit2Sharp.Tests.TestHelpers; using Xunit; -using System.Text.RegularExpressions; namespace LibGit2Sharp.Tests { @@ -87,40 +86,6 @@ namespace LibGit2Sharp.Tests } [Fact] - public void CanRetrieveValidVersionString() - { - // Version string format is: - // Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features) - // Example output: - // "0.17.0-unknown-06d772d (x86 - Threads, Https)" - - string versionInfo = Repository.Version; - - // The Repository.Version returned string should contain : - // version:'0.17.0' LibGit2Sharp version number. - // git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash. - // git2hash: '06d772d' LibGit2 library hash. - // arch: 'x86' or 'amd64' LibGit2 target. - // git2Features: 'Threads, Ssh' LibGit2 features compiled with. - string regex = @"^(?<version>\d{1,}\.\d{1,2}\.\d{1,3})-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$"; - - Assert.NotNull(versionInfo); - - Match regexResult = Regex.Match(versionInfo, regex); - - Assert.True(regexResult.Success, "The following version string format is enforced:" + - "Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)"); - - GroupCollection matchGroups = regexResult.Groups; - - // Check that all groups are valid - foreach(Group group in matchGroups) - { - Assert.True(group.Success); - } - } - - [Fact] public void CanCreateStandardRepoAndSpecifyAFolderWhichWillContainTheNewlyCreatedGitDirectory() { var scd1 = BuildSelfCleaningDirectory(); diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs index 0200a256..2cab50d5 100644 --- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs +++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs @@ -210,7 +210,7 @@ namespace LibGit2Sharp.Tests.TestHelpers throw new SkipException(message); } - protected void RequiresDotNetOrMonoGreaterThanOrEqualTo(Version minimumVersion) + protected void RequiresDotNetOrMonoGreaterThanOrEqualTo(System.Version minimumVersion) { Type type = Type.GetType("Mono.Runtime"); @@ -229,11 +229,11 @@ namespace LibGit2Sharp.Tests.TestHelpers var version = (string) displayName.Invoke(null, null); - Version current; + System.Version current; try { - current = new Version(version.Split(' ')[0]); + current = new System.Version(version.Split(' ')[0]); } catch (Exception e) { |