Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrkndrssn committed Sep 28, 2015
1 parent 6c4b85b commit 3c5726c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
71 changes: 71 additions & 0 deletions Octokit.Tests/Models/NewRepositoryWebHookTests.cs
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);
}
}
}
}
1 change: 1 addition & 0 deletions Octokit.Tests/Octokit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<Compile Include="Models\MilestoneRequestTests.cs" />
<Compile Include="Models\IssueRequestTests.cs" />
<Compile Include="Models\ModelExtensionsTests.cs" />
<Compile Include="Models\NewRepositoryWebHookTests.cs" />
<Compile Include="Models\PullRequestRequestTests.cs" />
<Compile Include="Models\PunchCardTests.cs" />
<Compile Include="Models\ReadOnlyPagedCollectionTests.cs" />
Expand Down

0 comments on commit 3c5726c

Please sign in to comment.