Skip to content

Commit

Permalink
Add unit test to ensure correct message is returned when duplicate ke…
Browse files Browse the repository at this point in the history
…ys exists.
  • Loading branch information
hnrkndrssn committed Oct 7, 2015
1 parent 0c73be9 commit df731f3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Octokit.Tests/Models/NewRepositoryWebHookTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class NewRepositoryWebHookTests
{
public class TheCtor
{
string ExpectedRepositoryWebHookConfigExceptionMessage =
"Duplicate webhook config values found - these values: Url should not be passed in as part of the config values. Use the properties on the NewRepositoryWebHook class instead.";

[Fact]
public void UsesDefaultValuesForDefaultConfig()
{
Expand Down Expand Up @@ -73,6 +76,33 @@ public void CombinesUserSpecifiedContentTypeWithConfig()
Assert.True(request.Config.ContainsKey("password"));
Assert.Equal(request.Config["password"], config["password"]);
}

[Fact]
public void ShouldThrowRepositoryWebHookConfigExceptionWhenDuplicateKeysExists()
{
var config = new Dictionary<string, string>
{
{"url", "http://example.com/test"},
{"hostname", "http://hostname.url"},
{"username", "username"},
{"password", "password"}
};

var create = new NewRepositoryWebHook("windowsazure", config, "http://test.com/example")
{
ContentType = WebHookContentType.Json,
Secret = string.Empty,
InsecureSsl = true
};

Assert.Equal(create.Url, "http://test.com/example");
Assert.Equal(create.ContentType, WebHookContentType.Json);
Assert.Empty(create.Secret);
Assert.True(create.InsecureSsl);

var ex = Assert.Throws<RepositoryWebHookConfigException>(() => create.ToRequest());
Assert.Equal(ExpectedRepositoryWebHookConfigExceptionMessage, ex.Message);
}
}
}
}

0 comments on commit df731f3

Please sign in to comment.