Added unittest to verify reading configuration for branches with dot in branch name

This commit is contained in:
Thomas Wurtz
2013-01-27 17:29:34 +01:00
parent 64e17b536f
commit dfab91cd41
2 changed files with 105 additions and 37 deletions
@@ -27,22 +27,18 @@ namespace Sep.Git.Tfs.Test.Core
[Fact]
public void DumpsMinimalRemote()
{
var remote = new RemoteInfo { Id = "default", Url = "http://server/path", Repository = "$/Project" };
var remoteId = "default";
var remote = new RemoteInfo { Id = remoteId, Url = "http://server/path", Repository = "$/Project" };
var config = _dumper.Dump(remote);
AssertContainsConfig("tfs-remote.default.url", "http://server/path", config);
AssertContainsConfig("tfs-remote.default.repository", "$/Project", config);
AssertContainsConfig("tfs-remote.default.username", null, config);
AssertContainsConfig("tfs-remote.default.password", null, config);
AssertContainsConfig("tfs-remote.default.ignore-paths", null, config);
AssertContainsConfig("tfs-remote.default.legacy-urls", null, config);
AssertContainsConfig("tfs-remote.default.autotag", null, config);
VerifyMinimalRemote(remoteId, config);
}
[Fact]
public void DumpsCompleteRemote()
{
var remoteId = "default";
var remote = new RemoteInfo {
Id = "default",
Id = remoteId,
Url = "http://server/path",
Repository = "$/Project",
Username = "user",
@@ -52,13 +48,57 @@ namespace Sep.Git.Tfs.Test.Core
Aliases = new string[] { "http://abc", "http://def" },
};
var config = _dumper.Dump(remote);
AssertContainsConfig("tfs-remote.default.url", "http://server/path", config);
AssertContainsConfig("tfs-remote.default.repository", "$/Project", config);
AssertContainsConfig("tfs-remote.default.username", "user", config);
AssertContainsConfig("tfs-remote.default.password", "pass", config);
AssertContainsConfig("tfs-remote.default.ignore-paths", "abc", config);
AssertContainsConfig("tfs-remote.default.legacy-urls", "http://abc,http://def", config);
AssertContainsConfig("tfs-remote.default.autotag", "true", config);
VerifyCompleteRemote(remoteId, config);
}
[Fact]
public void DumpsMinimalRemoteWithDotInName()
{
var remoteId = "maint-1.0.0.0";
var remote = new RemoteInfo { Id = remoteId, Url = "http://server/path", Repository = "$/Project" };
var config = _dumper.Dump(remote);
VerifyMinimalRemote(remoteId, config);
}
[Fact]
public void DumpsCompleteRemoteWithDotInName()
{
var remoteId = "maint-1.0.0.0";
var remote = new RemoteInfo
{
Id = remoteId,
Url = "http://server/path",
Repository = "$/Project",
Username = "user",
Password = "pass",
IgnoreRegex = "abc",
Autotag = true,
Aliases = new string[] { "http://abc", "http://def" },
};
var config = _dumper.Dump(remote);
VerifyCompleteRemote(remoteId, config);
}
private void VerifyMinimalRemote(string remoteId, IEnumerable<ConfigurationEntry> config)
{
AssertContainsConfig("tfs-remote." + remoteId + ".url", "http://server/path", config);
AssertContainsConfig("tfs-remote." + remoteId + ".repository", "$/Project", config);
AssertContainsConfig("tfs-remote." + remoteId + ".username", null, config);
AssertContainsConfig("tfs-remote." + remoteId + ".password", null, config);
AssertContainsConfig("tfs-remote." + remoteId + ".ignore-paths", null, config);
AssertContainsConfig("tfs-remote." + remoteId + ".legacy-urls", null, config);
AssertContainsConfig("tfs-remote." + remoteId + ".autotag", null, config);
}
private void VerifyCompleteRemote(string remoteId, IEnumerable<ConfigurationEntry> config)
{
AssertContainsConfig("tfs-remote." + remoteId + ".url", "http://server/path", config);
AssertContainsConfig("tfs-remote." + remoteId + ".repository", "$/Project", config);
AssertContainsConfig("tfs-remote." + remoteId + ".username", "user", config);
AssertContainsConfig("tfs-remote." + remoteId + ".password", "pass", config);
AssertContainsConfig("tfs-remote." + remoteId + ".ignore-paths", "abc", config);
AssertContainsConfig("tfs-remote." + remoteId + ".legacy-urls", "http://abc,http://def", config);
AssertContainsConfig("tfs-remote." + remoteId + ".autotag", "true", config);
}
private void AssertContainsConfig(string key, string value, IEnumerable<ConfigurationEntry> configs)
@@ -29,40 +29,57 @@ namespace Sep.Git.Tfs.Test.Core
Assert.Empty(_remotes);
}
void SetUpMinimalRemote()
private void SetUpMinimalRemote(string remoteId)
{
_config["tfs-remote.default.url"] = "http://server/path";
_config["tfs-remote.default.repository"] = "$/project";
_config["tfs-remote." + remoteId + ".url"] = "http://server/path";
_config["tfs-remote." + remoteId + ".repository"] = "$/project";
}
[Fact]
public void MinimalRemote()
{
SetUpMinimalRemote();
Assert.Equal(1, _remotes.Count());
Assert.Equal("default", _firstRemote.Id);
Assert.Equal("http://server/path", _firstRemote.Url);
Assert.Equal("$/project", _firstRemote.Repository);
Assert.Null(_firstRemote.Username);
Assert.Null(_firstRemote.Password);
Assert.Null(_firstRemote.IgnoreRegex);
var remoteId = "default";
SetUpMinimalRemote(remoteId);
VerifyMinimalRemote(remoteId);
}
void SetUpCompleteRemote()
private void SetUpCompleteRemote(string remoteId)
{
SetUpMinimalRemote();
_config["tfs-remote.default.username"] = "theuser";
_config["tfs-remote.default.password"] = "thepassword";
_config["tfs-remote.default.ignore-paths"] = "ignorethis.zip";
_config["tfs-remote.default.legacy-urls"] = "http://old:8080/,http://other/";
_config["tfs-remote.default.autotag"] = "true";
SetUpMinimalRemote(remoteId);
_config["tfs-remote." + remoteId + ".username"] = "theuser";
_config["tfs-remote." + remoteId + ".password"] = "thepassword";
_config["tfs-remote." + remoteId + ".ignore-paths"] = "ignorethis.zip";
_config["tfs-remote." + remoteId + ".legacy-urls"] = "http://old:8080/,http://other/";
_config["tfs-remote." + remoteId + ".autotag"] = "true";
}
[Fact]
public void RemoteWithEverything()
public void CompleteRemote()
{
SetUpCompleteRemote();
Assert.Equal("default", _firstRemote.Id);
var remoteId = "default";
SetUpCompleteRemote(remoteId);
VerifyCompleteRemote(remoteId);
}
[Fact]
public void MinimalRemoteWithDotInName()
{
var remoteId = "maint-1.0.0.0";
SetUpCompleteRemote(remoteId);
VerifyCompleteRemote(remoteId);
}
[Fact]
public void CompleteRemoteWithDotInName()
{
var remoteId = "maint-1.0.0.0";
SetUpCompleteRemote(remoteId);
VerifyCompleteRemote(remoteId);
}
private void VerifyCompleteRemote(string remoteId)
{
Assert.Equal(remoteId, _firstRemote.Id);
Assert.Equal("http://server/path", _firstRemote.Url);
Assert.Equal("$/project", _firstRemote.Repository);
Assert.Equal("theuser", _firstRemote.Username);
@@ -71,5 +88,16 @@ namespace Sep.Git.Tfs.Test.Core
Assert.Equal(new string[] { "http://old:8080/", "http://other/" }, _firstRemote.Aliases);
Assert.True(_firstRemote.Autotag);
}
private void VerifyMinimalRemote(string remoteId)
{
Assert.Equal(1, _remotes.Count());
Assert.Equal(remoteId, _firstRemote.Id);
Assert.Equal("http://server/path", _firstRemote.Url);
Assert.Equal("$/project", _firstRemote.Repository);
Assert.Null(_firstRemote.Username);
Assert.Null(_firstRemote.Password);
Assert.Null(_firstRemote.IgnoreRegex);
}
}
}