diff options
author | yorah <yoram.harmelin@gmail.com> | 2012-11-07 16:44:49 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-12-05 11:38:15 +0400 |
commit | 3cb5145c08fa6350ebdd82fcd9989a1cf0d1172a (patch) | |
tree | 668556ebf95414fb2ebf8f6aa51202598c82095a /LibGit2Sharp.Tests | |
parent | 0332c35dbaeebad177645bf62ad2c5efabefd17b (diff) |
Make repo.Config.Get() return the originating store
Signed-off-by: Unit Test <yoram.harmelin@gmail.com>
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/CommitFixture.cs | 12 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/ConfigurationFixture.cs | 63 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/RemoteFixture.cs | 8 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/RepositoryOptionsFixture.cs | 4 |
4 files changed, 40 insertions, 47 deletions
diff --git a/LibGit2Sharp.Tests/CommitFixture.cs b/LibGit2Sharp.Tests/CommitFixture.cs index f93d65cc..e25bcb52 100644 --- a/LibGit2Sharp.Tests/CommitFixture.cs +++ b/LibGit2Sharp.Tests/CommitFixture.cs @@ -500,12 +500,12 @@ namespace LibGit2Sharp.Tests AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n"); AssertBlobContent(commit[relativeFilepath], "nulltoken\n"); - var name = repo.Config.Get<string>("user.name", null); - var email = repo.Config.Get<string>("user.email", null); - Assert.Equal(commit.Author.Name, name); - Assert.Equal(commit.Author.Email, email); - Assert.Equal(commit.Committer.Name, name); - Assert.Equal(commit.Committer.Email, email); + var name = repo.Config.Get<string>("user.name"); + var email = repo.Config.Get<string>("user.email"); + Assert.Equal(commit.Author.Name, name.Value); + Assert.Equal(commit.Author.Email, email.Value); + Assert.Equal(commit.Committer.Name, name.Value); + Assert.Equal(commit.Committer.Email, email.Value); } } diff --git a/LibGit2Sharp.Tests/ConfigurationFixture.cs b/LibGit2Sharp.Tests/ConfigurationFixture.cs index 2e22010d..ac4b5fc1 100644 --- a/LibGit2Sharp.Tests/ConfigurationFixture.cs +++ b/LibGit2Sharp.Tests/ConfigurationFixture.cs @@ -50,14 +50,14 @@ namespace LibGit2Sharp.Tests var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath); using (var repo = new Repository(path.RepositoryPath)) { - Assert.False(repo.Config.Get<bool>("unittests.boolsetting", false)); + Assert.Null(repo.Config.Get<bool>("unittests.boolsetting")); repo.Config.Set("unittests.boolsetting", true); - Assert.True(repo.Config.Get<bool>("unittests.boolsetting", false)); + Assert.True(repo.Config.Get<bool>("unittests.boolsetting").Value); repo.Config.Unset("unittests.boolsetting"); - Assert.False(repo.Config.Get<bool>("unittests.boolsetting", false)); + Assert.Null(repo.Config.Get<bool>("unittests.boolsetting")); } } @@ -88,13 +88,13 @@ namespace LibGit2Sharp.Tests using (var repo = new Repository(BareTestRepoPath, options)) { Assert.True(repo.Config.HasGlobalConfig); - Assert.Equal(42, repo.Config.Get("Wow.Man-I-am-totally-global", 1337)); + Assert.Equal(42, repo.Config.Get<int>("Wow.Man-I-am-totally-global").Value); repo.Config.Unset("Wow.Man-I-am-totally-global"); - Assert.Equal(42, repo.Config.Get("Wow.Man-I-am-totally-global", 1337)); + Assert.Equal(42, repo.Config.Get<int>("Wow.Man-I-am-totally-global").Value); repo.Config.Unset("Wow.Man-I-am-totally-global", ConfigurationLevel.Global); - Assert.Equal(1337, repo.Config.Get("Wow.Man-I-am-totally-global", 1337)); + Assert.Null(repo.Config.Get<int>("Wow.Man-I-am-totally-global")); } } @@ -105,7 +105,7 @@ namespace LibGit2Sharp.Tests { InconclusiveIf(() => !repo.Config.HasGlobalConfig, "No Git global configuration available"); - Assert.NotNull(repo.Config.Get<string>("user.name", null)); + Assert.NotNull(repo.Config.Get<string>("user.name")); } } @@ -115,7 +115,7 @@ namespace LibGit2Sharp.Tests using (var config = new Configuration()) { InconclusiveIf(() => !config.HasGlobalConfig, "No Git global configuration available"); - Assert.NotNull(config.Get<string>("user.name", null)); + Assert.NotNull(config.Get<string>("user.name")); } } @@ -124,8 +124,7 @@ namespace LibGit2Sharp.Tests { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.True(repo.Config.Get<bool>("core.ignorecase", false)); - Assert.True(repo.Config.Get<bool>("core", "ignorecase", false)); + Assert.True(repo.Config.Get<bool>("core.ignorecase").Value); } } @@ -134,8 +133,7 @@ namespace LibGit2Sharp.Tests { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Equal(2, repo.Config.Get<int>("unittests.intsetting", 42)); - Assert.Equal(2, repo.Config.Get<int>("unittests", "intsetting", 42)); + Assert.Equal(2, repo.Config.Get<int>("unittests.intsetting").Value); } } @@ -144,8 +142,7 @@ namespace LibGit2Sharp.Tests { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Equal(15234, repo.Config.Get<long>("unittests.longsetting", 42)); - Assert.Equal(15234, repo.Config.Get<long>("unittests", "longsetting", 42)); + Assert.Equal(15234, repo.Config.Get<long>("unittests.longsetting").Value); } } @@ -154,8 +151,8 @@ namespace LibGit2Sharp.Tests { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote.origin.fetch", null)); - Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote", "origin", "fetch", null)); + Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote.origin.fetch").Value); + Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get<string>("remote", "origin", "fetch").Value); } } @@ -165,7 +162,7 @@ namespace LibGit2Sharp.Tests using (var repo = new Repository(StandardTestRepoPath)) { InconclusiveIf(() => !repo.Config.HasGlobalConfig, "No Git global configuration available"); - var entry = repo.Config.FirstOrDefault(e => e.Key == "user.name"); + var entry = repo.Config.FirstOrDefault<ConfigurationEntry<string>>(e => e.Key == "user.name"); Assert.NotNull(entry); Assert.NotNull(entry.Value); } @@ -176,7 +173,7 @@ namespace LibGit2Sharp.Tests { using (var repo = new Repository(StandardTestRepoPath)) { - var entry = repo.Config.FirstOrDefault(e => e.Key == "core.ignorecase"); + var entry = repo.Config.FirstOrDefault<ConfigurationEntry<string>>(e => e.Key == "core.ignorecase"); Assert.NotNull(entry); Assert.Equal("true", entry.Value); } @@ -201,7 +198,7 @@ namespace LibGit2Sharp.Tests { InconclusiveIf(() => !repo.Config.HasGlobalConfig, "No Git global configuration available"); - var existing = repo.Config.Get<string>("user.name", null); + var existing = repo.Config.Get<string>("user.name"); Assert.NotNull(existing); try @@ -212,7 +209,7 @@ namespace LibGit2Sharp.Tests } finally { - repo.Config.Set("user.name", existing, ConfigurationLevel.Global); + repo.Config.Set("user.name", existing.Value, ConfigurationLevel.Global); } } } @@ -224,7 +221,7 @@ namespace LibGit2Sharp.Tests { InconclusiveIf(() => !config.HasGlobalConfig, "No Git global configuration available"); - var existing = config.Get<string>("user.name", null); + var existing = config.Get<string>("user.name"); Assert.NotNull(existing); try @@ -235,7 +232,7 @@ namespace LibGit2Sharp.Tests } finally { - config.Set("user.name", existing, ConfigurationLevel.Global); + config.Set("user.name", existing.Value, ConfigurationLevel.Global); } } } @@ -295,14 +292,14 @@ namespace LibGit2Sharp.Tests AssertValueInLocalConfigFile(path.RepositoryPath, "stringsetting = Juliën$"); - string val = repo.Config.Get("unittests.stringsetting", ""); + string val = repo.Config.Get<string>("unittests.stringsetting").Value; Assert.Equal("Juliën", val); } // Make sure the change is permanent using (var repo = new Repository(path.RepositoryPath)) { - string val = repo.Config.Get("unittests.stringsetting", ""); + string val = repo.Config.Get<string>("unittests.stringsetting").Value; Assert.Equal("Juliën", val); } } @@ -312,24 +309,20 @@ namespace LibGit2Sharp.Tests { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Throws<ArgumentException>(() => repo.Config.Get<short>("unittests.setting", 42)); - Assert.Throws<ArgumentException>(() => repo.Config.Get<Configuration>("unittests.setting", null)); + Assert.Throws<ArgumentException>(() => repo.Config.Get<short>("unittests.setting")); + Assert.Throws<ArgumentException>(() => repo.Config.Get<Configuration>("unittests.setting")); } } [Fact] - public void ReadingValueThatDoesntExistReturnsDefault() + public void ReadingValueThatDoesntExistReturnsNull() { using (var repo = new Repository(StandardTestRepoPath)) { - Assert.Null(repo.Config.Get<string>("unittests.ghostsetting", null)); - Assert.Equal(0, repo.Config.Get<int>("unittests.ghostsetting", 0)); - Assert.Equal(0L, repo.Config.Get<long>("unittests.ghostsetting", 0L)); - Assert.False(repo.Config.Get<bool>("unittests.ghostsetting", false)); - Assert.Equal("42", repo.Config.Get("unittests.ghostsetting", "42")); - Assert.Equal(42, repo.Config.Get("unittests.ghostsetting", 42)); - Assert.Equal(42L, repo.Config.Get("unittests.ghostsetting", 42L)); - Assert.True(repo.Config.Get("unittests.ghostsetting", true)); + Assert.Null(repo.Config.Get<string>("unittests.ghostsetting")); + Assert.Null(repo.Config.Get<int>("unittests.ghostsetting")); + Assert.Null(repo.Config.Get<long>("unittests.ghostsetting")); + Assert.Null(repo.Config.Get<bool>("unittests.ghostsetting")); } } diff --git a/LibGit2Sharp.Tests/RemoteFixture.cs b/LibGit2Sharp.Tests/RemoteFixture.cs index dda9fdb0..2fc2bfad 100644 --- a/LibGit2Sharp.Tests/RemoteFixture.cs +++ b/LibGit2Sharp.Tests/RemoteFixture.cs @@ -165,10 +165,10 @@ namespace LibGit2Sharp.Tests Assert.Equal(name, remote.Name); Assert.Equal(url, remote.Url); - var refSpec = repo.Config.Get<string>("remote", remote.Name, "fetch", null); + var refSpec = repo.Config.Get<string>("remote", remote.Name, "fetch"); Assert.NotNull(refSpec); - Assert.Equal("+refs/heads/*:refs/remotes/upstream/*", refSpec); + Assert.Equal("+refs/heads/*:refs/remotes/upstream/*", refSpec.Value); } } @@ -185,10 +185,10 @@ namespace LibGit2Sharp.Tests repo.Remotes.Add(name, url, fetchRefSpec); - var refSpec = repo.Config.Get<string>("remote", name, "fetch", null); + var refSpec = repo.Config.Get<string>("remote", name, "fetch"); Assert.NotNull(refSpec); - Assert.Equal(fetchRefSpec, refSpec); + Assert.Equal(fetchRefSpec, refSpec.Value); } } } diff --git a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs index a5c3d2a8..2c6084ae 100644 --- a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs @@ -167,8 +167,8 @@ namespace LibGit2Sharp.Tests using (var repo = new Repository(BareTestRepoPath, options)) { Assert.True(repo.Config.HasGlobalConfig); - Assert.Equal(name, repo.Config.Get<string>("user", "name", null)); - Assert.Equal(email, repo.Config.Get<string>("user", "email", null)); + Assert.Equal(name, repo.Config.Get<string>("user.name").Value); + Assert.Equal(email, repo.Config.Get<string>("user.email").Value); repo.Config.Set("help.link", "https://twitter.com/xpaulbettsx/status/205761932626636800", ConfigurationLevel.System); } |