-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c4b85b
commit 3c5726c
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Models | ||
{ | ||
public class NewRepositoryWebHookTests | ||
{ | ||
public class TheCtor | ||
{ | ||
[Fact] | ||
public void UsesDefaultValuesForDefaultConfig() | ||
{ | ||
var create = new NewRepositoryWebHook("windowsazure", new Dictionary<string, string>(), "http://test.com/example"); | ||
|
||
Assert.Equal(create.Config.Count, 4); | ||
|
||
Assert.True(create.Config.ContainsKey("url")); | ||
Assert.True(create.Config.ContainsKey("content_type")); | ||
Assert.True(create.Config.ContainsKey("secret")); | ||
Assert.True(create.Config.ContainsKey("insecure_ssl")); | ||
|
||
Assert.Equal(create.Config["url"], "http://test.com/example"); | ||
Assert.Equal(create.Config["content_type"], WebHookContentType.Form.ToParameter()); | ||
Assert.Equal(create.Config["secret"], ""); | ||
Assert.Equal(create.Config["insecure_ssl"], "0"); | ||
|
||
Assert.Equal(create.Url, "http://test.com/example"); | ||
Assert.Equal(create.ContentType, WebHookContentType.Form); | ||
Assert.Empty(create.Secret); | ||
Assert.False(create.InsecureSsl); | ||
} | ||
|
||
[Fact] | ||
public void CombinesUserSpecifiedContentTypeWithConfig() | ||
{ | ||
var config = new Dictionary<string, string> | ||
{ | ||
{"hostname", "http://hostname.url"}, | ||
{"username", "username"}, | ||
{"password", "password"} | ||
}; | ||
|
||
var create = new NewRepositoryWebHook("windowsazure", config, "http://test.com/example", WebHookContentType.Json, string.Empty, true); | ||
|
||
Assert.Equal(create.Config.Count, 7); | ||
|
||
Assert.True(create.Config.ContainsKey("url")); | ||
Assert.True(create.Config.ContainsKey("content_type")); | ||
Assert.True(create.Config.ContainsKey("secret")); | ||
Assert.True(create.Config.ContainsKey("insecure_ssl")); | ||
|
||
Assert.Equal(create.Config["url"], "http://test.com/example"); | ||
Assert.Equal(create.Config["content_type"], WebHookContentType.Json.ToParameter()); | ||
Assert.Equal(create.Config["secret"], ""); | ||
Assert.Equal(create.Config["insecure_ssl"], "1"); | ||
|
||
Assert.True(create.Config.ContainsKey("hostname")); | ||
Assert.Equal(create.Config["hostname"], config["hostname"]); | ||
Assert.True(create.Config.ContainsKey("username")); | ||
Assert.Equal(create.Config["username"], config["username"]); | ||
Assert.True(create.Config.ContainsKey("password")); | ||
Assert.Equal(create.Config["password"], config["password"]); | ||
|
||
Assert.Equal(create.Url, "http://test.com/example"); | ||
Assert.Equal(create.ContentType, WebHookContentType.Json); | ||
Assert.Empty(create.Secret); | ||
Assert.True(create.InsecureSsl); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters